simplexml

Using xpath on a PHP SimpleXML object, SOAP + namespaces (not working..)

Hello, After researching this on SO and google for hours now... I hope to get some help here: (I am just one step away from running a regex to remove the namespaces completely) First this is the XML: <?xml version="1.0" encoding="utf-16"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; <soap:Header xmlns="...

Parsing XML with keys that have spaces in their names

Does anyone know how to parse an xml string in php using SimpleXMLElement when the key has a space in it ? For example, $xmlString = "<test><this is>a</this is></test>"; $xml = new SimpleXMLElement($xmlString); print_r($xml); in the above example, 'this is' causes the parser to go bananas. I'm guessing its because it thinks its a pro...

How Can I Remove Magic Number when using XML::Simple?

Hello. I did a exercise like this, how do I calculate the # of XML elements collapsed into an array by XML::Simple so I don't have to hard-code the # of elements? I plan to use the code to parse a bigger xml file. I don't want to cout the elements by manual. Can I use some count to replace the magic numbers, a little like person.count...

Easy PHP SimpleXML Issue

Hi all, I've got a really bad brain block with this. My XML file looks like this: <?xml version="1.0" encoding="UTF-8"?> <data> <fruits> <item>Apple</item> <item>Orange</item> <item>Banana</item> </fruits> <vegetables> <item>Lettuce</item> <item>Carrot</item> </vegetables> </data> I am tyring to use Simpl...

How would I call this element via SimpleXML?

How would I call this element via SimpleXML? $xml->ls:viewMinutesThisWeek definitely wouldn't work <ls:viewerMinutesThisWeek>5700</ls:viewerMinutesThisWeek> ...

php - simplexml issue

Hello, I have an xml file that has attributes/tags for mutliple levels in the feed however simplexml isn't showing them in the print_r dump. Example: <types tag1="1287368759" tag2="1287368759"> <locations> <segment prefix="http" lastchecked="0">www.google.com</segment> <segment prefix="http" lastchecked="0">www.goo...

Insert an xml element from an xml doc to an other xml document

Let's say I have to xml documents: <first_root> <element1/> <element2> <embedded_element/> </element2> </first_root> and <foo> <bar/> </foo> How can I put this second xml doc into the first one, using php and DomDocument or SimpleXML? I want it to look like something like this: <first_root> <element1/> <element2> ...

xpath to get all elements

I am using simplexml to parse xml and I can get single node but not all nodes i want example $xmlObject = simplexml_load_file($xml_file); // load the xml file $cols = $xmlObject->RESULTSET->ROW->COL; foreach ( $cols as $COL) { echo $COL->DATA; } only gives me the first col of the first row, i tried $x...

parsing/searching a beastly array filled with simple xml objects in php

Hi, So Im working on a Excel xml parsing class, and Im trying to search through an array of the header values of the file, to return the key integer. If I can get the key int, then I can grab an entire column by the value of the header in the file. I have tried using in_array, search_array and a bunch of other functions, but nothing is ...

problem with SimpleXML and inclosed arrays

I'm having a problem with SIMPLE XML. I seem to have an array with dumping the whole object. However, when I try to access the array, I get a single element of the array back. Here is the full dump: SimpleXMLElement Object ( [@attributes] => Array ( [type] => array ) [person] => Array ( ...

How to convert an XML FIle into a SimpleXMLElement() Array?

I have an XML File: <?xml version="1.0" encoding="iso-8859-1"?> <deadlines> <deadline> <date>2010-07-01</date> <text>Residency Application for Fall Due</text> </deadline> <deadline> <date>2010-06-01</date> <text>Residency Application for Summer Due</text> </deadline> <deadline> ...

Is this the correct way to access a simplexml object's contents?

$test_string = '<a href="#">blah blah</a>'; $test_obj = simplexml_load_string($test_string); fb((string)$test_obj[0]); I thought I could just access the contents of the anchor tag by doing $test_obj[0]. I'm doing this to move away from using regular expressions to access individual html elements and properties in PHP. Is this cas...

Looping through SimpleXMLElement Object works only in 2 steps

I've got a SimpleXMLElement for which I read in a XML file using curl. Trying to get the values out of it I seem to need to use a nested foreach, but in a similar situation I was able to do this in one go. Now I'm really curious why this isn't working: Its the delicious RSS feed; SimpleXMLElement Object ( [title] => Delicious/chr...

Using PHP to manage GMail Mail Filter XML Files

Since GMail made it possible to import and export the mail filters, I'd like to manage the XML files that are exported from GMail using a PHP script, as there are some known issues with the number of characters in the search filters. I've found the simplexml_load_file function in PHP, and have performed var_dump() against the performed ...

can i use simpleXML & xpath to directly select an elements attribute?

i.e. - i want to return a string "yellow" using something like xpath expression "//banana/@color" and the following example xml... <fruits> <kiwi color="green" texture="hairy"/> <banana color="yellow" texture="waxy"/> </fruits> $fruits = simplexml_load_string( '<fruits> <kiwi color="green" texture="hairy"/> <banana color="yellow" ...

php/simplexml: parsing image out of node

I have a feed with images in the description node. How can I parse out just the image URL and just the description text with no line break in between? <description>&lt;img src='http://example.com/100915gignac-clement_g_70x70.jpg'&amp;gt;&amp;lt;/img&amp;gt;&amp;lt;br /&gt;(Source: Example.com) Québec annonce qu'une autorisation ministé...