simplexml

php - how to display values from a SimpleXMLElement

how do i display individual values from the following code? SimpleXMLElement Object ( [@attributes] => Array ( [stat] => ok ) [profile] => SimpleXMLElement Object ( [address] => SimpleXMLElement Obje...

Mixing childs with cdata under the same node. Is it valid?

Hi, I need to parse the following xml document (which is coming from external web service): ... <dati> <Riconoscimento> <IdentificativoPosizione>xxxx</IdentificativoPosizione> <OutputRestituiti>xxx</OutputRestituiti> </Riconoscimento> <![CDATA[text text text]]> </dati> ... The problem is that until ther...

reading twitter's rss search feed with simple xml

Having some trouble selecting some nodes in the rss feed for twitter's search the rss url is here http://search.twitter.com/search.rss?q=twitfile each item looks like this <item> <title>RT @TwittBoy: TwitFile - Comparte tus archivos en Twitter (hasta 200Mb) http://bit.ly/xYNsM&lt;/title&gt; <link>http://twitter.com/MarielaCelita...

How to to sort a XML feed with SimpleXML

Hi, I have started to use the simplexml function that seems to work out better than the previous other parser that I have tried to use. I have got to the stage where I need to the sort the items by transmissiondate - I tried using the uasort but does not make any changes the order of the items. also some times a programme is on more t...

Convert multi-dimensional multi-object array to standard multi-dimensional array in PHP

I have a multi-dimensional multi-object array from a simplexml_import_dom() function call. A slice of one section of the array: [Price] => SimpleXMLElement Object ( [Prices] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( ...

How to access value from within multi-dimensional object in php

Here is a slice of the array in question: Array ( [Pricing] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [MType] => A [PType] => JBN ) ...

using php xmlreader to get data from xml to mysql

I am using php and xmlreader to retreive data from an xml file and insert into a mysql table. I chose xmlreader because the files supplied me are 500mb. I am new to all of this and am at a sticking point getting the data to insert properly into the mysql table. Sample xml from file... <us:ItemMaster> <us:ItemMasterHeader> <oa:I...

Adding a block of XML as child of a SimpleXMLElement object

Hey all, I have this SimpleXMLElement object with a XML setup similar to the following... $xml <<< EOX <books> <book> <name>ABCD</name> </book> </books> EOX; $sx = new SimpleXMLElement( $xml ); Now I have a class named Book that contains info. about each book. The same class can also spit out the book info. in XML...

How to use XMLREADER in php?

I have the following XML file, the file is rather large and i haven't been able to get simplexml to open and read the file so i'm trying XMLREADER with no success in php <?xml version="1.0" encoding="ISO-8859-1"?> <products> <last_updated>2009-11-30 13:52:40</last_updated> <product> <element_1>foo</element_1> <element_...

PHP SimpleXML new line

Hi, I have created a XML file using PHP's simple XML, saved the file. When opening the file in php using fopen and printing the contents. my XML looks like this: (see below) <?xml version="1.0" encoding="UTF-8"?> <home><orderList><delivery_cost>0.00</delivery_cost><delivery_surname>TEST</delivery_surname><delivery_postcode>1234</delive...

PHP SimpleXML Error Message

Warning: main() [function.main]: Node no longer exists I am loading a ml file via simplexml_load_file, it sometimes has values for an attribute and sometimes does not. Usage: $value = $xml->Name->arttributes(); Echo $value; how do I error check to see if there is a value without getting a warning. Thanks ...

Retrieving a subset of XML nodes with PHP

Using PHP, how do I get an entire subset of nodes from an XML document? I can retrieve something like: <?xml version="1.0" encoding="utf-8"?> <people> <certain> <name>Jane Doe</name> <age>21</age> </certain> <certain> <certain> <name>John Smith</name> <age>34</age> </certain> </people> But what if I only want...

Basic simpleXML working example?

Hi It looks like there are many problems with simpleXML in PHP. I'm running the latest version of php on Windows and I just can not get the basic examples of simpleXML to work as in the documentation. My xml file is: <?xml version="1.0" encoding="ISO-8859-1"?> <programme> <title>Billy Bushwaka</title> <episodeNumber>2</epis...

PHP SimpleXML with xpath

I have a small XML file: <wddxPacket version='1.0'> <header/> <data> <struct type='coldfusion.runtime.ArgumentCollection'> <var name='HEADLINE'> <string>Richard Barret's Articles on Leadership and High Performance Organisations</string> </var> </struct> </data> </wddxPacket> I'm trying to use PHP Simp...

XML with xpath and PHP: How to access the text value of an attribute of an entry

xml: <entry> <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/xy/albumid/531885671007533108" /> <link rel="alternate" type="text/html" href="http://picasaweb.google.com/xy/Cooking" /> <link rel="self" type="application/atom+xml" href="http://picasa...

php simple xml element question/bug

Hey there, I have some xml, lets say <names number="12"></names> When I run the following: $simpleXMLElement = new SimpleXMLElement($xml); pr($simpleXMLElement); I get the following: SimpleXMLElement Object ( [@attributes] => Array ( [number] => 12 ) [0] => ) It throws in that 0 entry. This ...

PHP simplexml_load_file - catch file errors

Hi, Is it possible to catch simplexml file errors? I'm connecting to a webservice that sometimes fails, and I need to make the system skip a file if it returns some http error or something similar. Thanks! ...

PHP - Loop through files on server and run script for each file

Hello I will try to explain as well as possible what I'm trying to do. I have a folder on a server with about 100 xml files. These xml files are content pages with text and references to attachment filenames on the server that will be pushed to a wiki through an API. It's all working fine 1 XML file at a time but I want to loop throug...

Compare XML in PHP without hashing

I am reading an XML feed and would like to compare to an old version to check for updates. My problems at the moment are that I can't seem to make a copy of a SimpleXML object and the other problem is I'm not sure I can directly compare them. This is my code as it stands, feel free to shoot me down if it's rubbish. I'm obviously just tes...

PHP SimpleXML get innerXML

I need to get the HTML contents of answer in this bit of XML: <qa> <question>Who are you?</question> <answer>Who who, <strong>who who</strong>, <em>me</em></answer> </qa> So I want to get the string "Who who, <strong>who who</strong>, <em>me</em>". If I have the answer as a SimpleXMLElement, I can call asXML() to get "<answer>Who w...