simplexml

getting only subsequent siblings of same type using xpath and simplexml

I need to parse a html definition list like the following: <dl> <dt>stuff</dt> <dd>junk</dd> <dd>things</dd> <dd>whatnot</dd> <dt>colors</dt> <dd>red</dd> <dd>green</dd> <dd>blue</dd> </dl> So that I can end up with an associative array like this: [definition list] => [stuff...

Parsing XML using SimpleXML in PHP

Hello, i have a xml structure of the following form to be parsed using PHP simplexml. <books> <book> <title>XYZ</title> <author> someone </author> <images> <image type="poster" url="<url>" size="cover" id="12345"/> <image type="poster" url="<url>" size="thumb" id="12345"/> </images> </book> <book> <title>PQR</title> <author> someonee...

Problem with element attribute in php simplexml

Hello, i have a xml structure of the following form to be parsed using PHP simplexml. <books> <book> <title>XYZ</title> <author> someone </author> <images> <image type="poster" url="<url>" size="cover" id="12345"/> <image type="poster" url="<url>" size="thumb" id="12345"/> </images> </book> <book> <title>PQR</title> <author> someonee...

access namespace element/attribute in xml/atom document with simplexml

Hello, I may have a simple question, I need to know how to get to nested namespace attributes/elements like below <gf:marketValue> <gd:money amount='150990.0' currencyCode='USD'/> </gf:marketValue> this is from the google-api Also, I am now not sure wich one I should use the url .../portfolio or portfolio/1/positions to get t...

SimpleXML: Working with XML containing namespaces

I am trying to get to the geo information off the google-picasa API. This is the original XML: <georss:where> <gml:Point> <gml:pos>35.669998 139.770004</gml:pos> </gml:Point> </georss:where> I already have come this far, with: $ns_geo=$item->children($namespace['georss']); $geo=$ns_geo->children($namespace['gml']); var_dump...

Porting code that used SimpleXML to Dom in PHP

I have a class that extends PDO to give it the ability to pull the configuration from an xml file. Unfortunately the our hosting provider has disabled SimpleXML so I need to refactor my code to use Dom, which is available. I am using the following code: class xmlPDO extends PDO { public function __construct($xml_uri){ $xml...

Simple XML HELP !!!!

Hi , I need some help , All I need to do is change "HERE" to a the value of $date $line1 = $sxe->addChild("date","HERE"); How can I add the value of $date into the area were "HERE" is ? Please help ...

Removing inline elements when importing HTML into DOMDocument or SimpleXML?

I have an external HTML source that I want to scrape and either transform into a local XML file or add to a MySQL DB. The external source is mostly normalized and (somewhat) semantic, so that all I need to do is use XPATH to get all td content or all li content, etc. The problem is that occasionally these items use <strong> or <b> or <i...

SimpleXML how to prepend a child in a node?

When I call addChild('actor', 'John Doe'); this child is added in the last. Is there a way to make this new child a first child? ...

edit XML with simpleXML

Hi , How can I edit the value's in a xml file using simpleXML ? I know how to create just not how to edit the value in a exciting file ? ...

how to get simpleXML to create an ID

Hi , I have an exctiing xml file which has id's 1 - 20 when I create a new xml file I need it to add the ID to the file how can I do this ? I know how you would do it with SQL but not with xml please help ...

PHP namespace simplexml problems

Evening guys. Firstly to say, I have read http://stackoverflow.com/questions/1133897/how-do-i-parse-xml-containing-custom-namespaces-using-simplexml. I'm parsing an XML document from a source not mind, and they use a custom namespace. <?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:moshtix="http://www.moshtix.com.au"&g...

How to order simpleXML loop

Hi , I neeed to order my loop by the id my xml doc looks like this <gig id="16"> <date>Fri. 23rd Apr</date> <venue>Sneaky Pete's</venue> <area>Edinburgh</area> <telephone>www.ticketweb.co.uk</telephone> <price>£10</price> <time>Time TBA</time> </gig> So as you can see I nee...

Finding the value of a child in a specific attribute

<data> <gig id="1"> <date>December 19th</date> <venue>The Zanzibar</venue> <area>Liverpool</area> <telephone>Ticketline.co.uk</telephone> <price>£6</price> <time>Time TBA</time> </gig> <gig id="2"> <date>Sat. 16th Jan</date> <venue>Celtic Connection, Classic Grand</venue> <area>Glasgow</area> ...

auto increment for simpleXML

Hi I have my simpleXML script creating new element's in a xml file but I need the attribute to be a auto incremented id for example <gig id="1"> <date>December 19th</date> <venue>The Zanzibar</venue> <area>Liverpool</area> <telephone>Ticketline.co.uk</telephone> <price>£6</price> <tim...

problems geting values from xml

Im trying to get some values from the below xml feed <?xml version="1.0" ?> <SEARCH> <LOCATION> <NAME>Terrance</NAME> <COUNTRY>USA</COUNTRY> </LOCATION> <FOUND> <TOTALOFOUND> <TOTAL>3</TOTAL> </TOTALOFOUND> <PLACE> <ADDRESS>IL Road</ADDRESS> <NAME>shop1</NAME> <POSTCODE>5</POSTCODE> <CAT...

PHP simplexml_load_file catch 403

I am using the following PHP: $xml = simplexml_load_file($request_url) or die("url not loading"); I use: $status = $xml->Response->Status->code; To check the status of the response. 200 bening everything is ok, carry on. However if I get a 403 access denied error, how do I catch this in PHP so I can return a user friendly warning?...

Simplexml is giving me the wrong results

I have a simple xml below: <?xml version="1.0" encoding="utf-8"?> <catalogue> <category name="textbook" id="100" parent="books"> <product id="20000"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publis...

Sorting an array of SimpleXML objects

I've read what I've found on Stackoverflow and am still unclear on this. I have an array of SimpleXML objects something like this: array(2) { [0]=> object(SimpleXMLElement)#2 (2) { ["name"]=> string(15) "Andrew" ["age"]=> string(2) "21" } [1]=> object(SimpleXMLElement)#3 (2) { ["name"]=> string(12) "Be...

PHP SimpleXML with XPath

I have an XML structure that looks like this: <?xml version="1.0"?> <survey> <responses>0</responses> <question> <title>Some survey question</title> <answer> <title>Answer 1</title> <responses>0</responses> </answer> <answer> <title>Answer 2</title> <responses>0</responses> </answer> ....