simplexml

PHP's SimpleXML: How to use colons in names

I am trying to generate an RSS Google Merchant, using SimpleXML. The sample given by Google is: <?xml version="1.0"?> <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"&gt; <channel> <title>The name of your data feed</title> <link>http://www.example.com&lt;/link&gt; <description>A description of your content</description> <ite...

PHP Session problem, copying object rather than just value

Hello, I'm having some trouble using sessions with php.. I think I have figured out why, it seems that when I set the session variable it is copying the entire SimpleXMLElement object rather than just the value stored in said object. How can I make sure to just store the value in my session variable?? Here are some code snippets: $re...

SimpleXML SOAP response Namespace issues

Hi. After spending SEVERAL frustrated hours on this I am asking for your help. I am trying to get the content of particular nodes from a SOAP response. The response is <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="<a href="http://www.w3.org/2003/05/soap-envelope"&gt;http://www.w3.org/2003/05/soap-envelope&lt;/a&gt;...

PHP sorting issue with simpleXML

test.xml: <?xml version="1.0"?> <props> <prop> <state statename="Mississippi"> <info> <code>a1</code> <location>Jackson</location> </info> <info> <code>d2</code> <location>Gulfport</location> </info> <info> <code>g6</code> <location>Hattiesburg</location> </info> </...

Populating XML file in PHP

Currently, a friend of mine is wanting a Flash Gallery and the ability to upload files. I don't have the time of day to teach him where to edit the XML properly or dare I even give him FTP access. He hand picked out this gallery program: http://flashnifties.com/xml_gallery.php Which as you can tell works off XML. Creating a script to h...

php , SimpleXML, while loop

I'm trying to get some information from ebay api and store it in database . I used simple xml to extract the information but I have a small issue as the information is not displayed for some items . if I make a print to the simple_xml I can see very well that the information is provided by ebay api . I have $items = "220617293997,25064...

Getting information from an XML object in PHP

Hi! I am using some XML parser to get some information from API, blah blah... :) In one place in my script, I need to convert string to int but I'm not sure how... Here is my object: object(parserXMLElement)#45 (4) { ["name:private"]=> string(7) "balance" ["data:private"]=> object(SimpleXMLElement)#46 (1) { [0]=> strin...

php , SimpleXML, extract info from array

I'm trying to extract some information from ebay api . I have this link up http://open.api.ebay.com/shopping?callname=GetMultipleItems&amp;responseencoding=XML&amp;appid=Morcovar-c74b-47c0-954f-463afb69a4b3&amp;siteid=0&amp;version=525&amp;IncludeSelector=ItemSpecifics&amp;ItemID=220617293997,250645537939,230485306218 and I'm using Simpl...

iterating SimpleXml xpath result

I'm using SimpleXMLElement to read xml returned from a remote server. The results are then parsed with xpath like this: $result = <<<XML <DataImport2Result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.xxx.xxx/Services/DataImport2"&gt; <Number /> <Blocks> ...

SimpleXML and print_r() - why is this empty?

Hi there here is my xml file: (thefile) <?xml version="1.0" encoding="utf-8"?> <ArrayOfItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://nts-de-osm1-pxc/webservices/"&gt; <Item xmlns:q1="http://systinet.com/wsdl/com/osm/webservices/service/" xsi:type="q1:Document"> ...

print element of array within array

hi this is my array structure. i want to print title track id . Array ( [@attributes] => Array ( [type] => array ) [track] => SimpleXMLElement Object ( [id] => 3617316 [created-at] => 2010-06-24T09:09:23Z [user-id] => 1219873 [p...

How can I set text value of SimpleXmlElement without using its parent?

I want to set text of some node found by xpath() <?php $args = new SimpleXmlElement( <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML ); // I want to set text of some node found by xpath // Let's take (//c) for example // convoluted and I can't be sure I'm setting right node $firstC = r...

Simplexml_load_string($string) returns an empty object but $string contains xml? code below

Hello I retrieve some information using cURL in xml format. .... $xml = curl_exec($ch); $data = simplexml_load_string($xml); print_r($data); //out put - SimpleXMLElement Object ( ) if I try - print_r($xml); and view page source I get <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns7:users xmlns="http://www.examp...

How can I reconstruct a paginated XML document?

I'm reading from an API that returns paginated XML. The basic format of the API's output is: <candidates.list page="1" next_page="yes"> <candidate /> <candidate /> <candidate /> </candidates.list> My code is like this: while (TRUE) { $xml_str = file_get_contents($dest) $xml = new SimpleXMLElement($xml_str); // What shou...

SimpleXML won't return data properly

I'm using SimpleXML to parse a data file from an external source. I'm trying to pull a thumbnail from the result, which looks like this: <entry> <title>Ball_Punch</title> <author> <name>burningcandle2010</name> <uri>https://www.mochimedia.com/community/profile/burningcandle2010&lt;/uri&gt; ...

Add child to xml with PHP simpleXml

Hello, i have problem with simpleXml and adding new items. This is my xml: <?xml version="1.0" encoding="utf-8"?> <root> <items> <item>abc</item> <item>def</item> <item>ghi</item> </items> </root> Im using this php code: $xml = simplexml_load_file("myxml.xml"); $sxe = new SimpleXMLElement($xml->asXML());...

php simplexml: how can i load an html file?

When I try to load an html file as xml using simplexml_load_string i get many errors and warnings regarding the html and it fails, it there a way to properly load an html file using simplexml ? this html file may have unneeded spaces and maybe some other errors that i would like simplexml to ignore. ...

Xpath path help

I have the following XML: <products> <product> <name>Flat Panel Monitor</name> <code>LS123</code> <attributes> <attribute> <group>Color</group> <values> <value>Red</value> <value>Blue</value> <value>...

Parse error: syntax error, unexpected T_OBJECT_OPERATOR

I'm getting the following error when trying to add some data from myXml.xml to a string: Parse error: syntax error, unexpected T_OBJECT_OPERATOR. $xmlstr = file_get_contents('myXml.xml'); $xml = new SimpleXMLElement($xmlstr); foreach($xml->order as $order){ $replace = array(); $firstName = (string) ...

SimpleXML loop works but breaks half way through

I have a loop going through results from a youtube feed and it works fine but towards the end it fails with the error: Warning: main() [function.main]: Node no longer exists in ../youtubereader.php on line 8 Warning: main() [function.main]: Node no longer exists in .../youtubereader.php on line 8 Fatal error: Call to a member function a...