simplexml

Using simpleDom.php to parse an xml file works fine in windows but failsin unix .

Using simpleDom.php to parse an xml file works fine in windows but failsin unix . <br /> <b>Fatal error</b>: Uncaught exception 'InvalidArgumentException' with message 'chunk is not well balanced ' in SimpleDOM.php:576 Stack trace: #0 lib.php(367): SimpleDOM-&gt;insertXML('&lt;prebuilt.credi...') #1 save_document....

PHP SimpleXML DOM using between functions

Hi there, I have been trying to get my head around how simplexml and dom updates XML between functions. The reason i ask is that the code i have written seems to work, but without me having to declare anything as global, and im a little confused as to why it does this. For example, i have this (simplified) code: <? foreach ($filename...

Extracting XML with PHP

I know how to use simplexml_load_file to get XML results if the XML format is <bowlcontents> <banana>yellow</banana> <apple>red</apple> </bowlcontents> However, I have some code that is in the format <bowlcontents> <fruit type="banana" skin="yellow" /> <fruit type="apple" skin="red" /> </bowlcontents> and I want to mani...

Get simpleXMLElement with jQuery

How do I retrieve the contents of a simpleXMLElement variable from a php file with jquery? ...

How can I limit the total number of SimpleXML results?

I'm looking to limit to the first 5 results returned here. This works, but it does not limit the data set: <?php foreach($sxml->status as $status){ $name = $status->user->name; $image =$status->user->profile_image_url; $update =$status->text; $url = "http://twitter.com/" .$status->user->screen_name; echo "<li><a href=\"" . $url . "\"...

Get xpath of xml node within recursive function

Lets say i have some code to iterate through an XML file recursively like this: $xmlfile = new SimpleXMLElement('http://www.domain.com/file.xml',null,true); xmlRecurse($xmlfile,0); function xmlRecurse($xmlObj,$depth) { foreach($xmlObj->children() as $child) { echo str_repeat('-',$depth).">".$child->getName().": ".$subchild."\n"; ...

Why can't I select the desired node using this PHP Xpath expression ?

Using PHP, SimpleXML and the xpath() function, I want to select a child node, starting from a certain point. Can you please help me? I know in this specific case I could use an expression starting with "//", but I want to learn the right way of selecting a child node. Thanks. First try -- fails with Undefined offset: 0 error $navXmlOb...

Can PHP SimpleXML be used for this task?

I'm looking to run some kind of loop on some optional XML data. Nodes would potentially look like this: <link1> <url>http://www.bleh.com&lt;/url&gt; <text>Click here</text> </link1> <link2> <url>bleh.com</url> <text>Click here</text> </link2> What would be the best method to determine if these nodes exist and parse them according...

How can I properly parse a SimpleXML Object in PHP?

I'm using the CloudFusion class to get Amazon.com data and my code is simple: $items = $pas->item_search( "shoes", array( "ResponseGroup" => "Small", "SearchIndex" => "Blended" )); $items = $items->body->Items; echo "<pre>"; print_r( $items ); echo "</pre>"; This returns the following: SimpleXMLElement Object ( [Request...

simplexml_load_file and $_SESSION

Hi everyone, I have a problem using simplexml_load_file and session vars in PHP. So, I have 2 PHP files, one generates some XML and the other one reads it. The file that generates XML should read some $_SESSION vars, which had been set in the other, but it won't... For instance, say the first file is something like: FILE 1 (reads XM...

How can this xpath query (PHP) be more flexible?

I'm parsing an XHTML document using PHP's SimpleXML. I need to query a series of ul's in the document for a node containing a specific value, then find that node's parent's direct previous sibling... code will help explain! Given the following dummy xhtml: <html> <head></head> <body> ... <ul class="attr-list"> <li>Active Life (ac...

PHP - Duplicate XML node using Simple XML

I need to load an XML source using Simple XML, duplicate an existing node with all his children, then customize an attribute of this new node before rendering XML. Any suggestion? ...

PHP, SimpleXML, how to access <tag> by its id attribue and now array position ?

Hi, I would like to understand how to access a by its id and not trough array position, example, I dont want to do this, $myXML->someNameHere[1]->home[0] I want to go access someNameHere by its ID "hi" Thanks a lot for your atention, ;D ...

PHP SimpleXML, how to set attributes ?

Hi, if you've got something like, <hello id="1" name="myName1"> <anotherTag title="Hello"> </anotherTag> </hello> <hello id="2" name="myName2"> <anotherTag title="Hi"> </anotherTag> </hello> How to change the attributes of, for example, hello id 2, to name="William" ? Or the title hi to hello ? Thanks a lot for your atention, H'...

PHP SimpleXML recursive function to list children and attibutes

I need some help on the SimpleXML calls for a recursive function that lists the elements name and attributes. Making a XML config file system but each script will have it's own config file as well as a new naming convention. So what I need is an easy way to map out all the elements that have attributes, so like in example 1 I need a simp...

Parsing XML with PHP's simpleXML

I'm learning how to parse XML with PHP's simple XML. My code is: <?php $xmlSource = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <Document xmlns=\"http://www.apple.com/itms/\" artistId=\"329313804\" browsePath=\"/36/6407\" genreId=\"6507\"> <iTunes> myApp </iTunes> </Document>"; $xml = new SimpleXMLElement($xmlS...

Isolate a single item from XML feed with PHP

Hi and thanks for looking. I'm trying to get just the value in brackets after 1 GBP = USD from the following link, how do I do this with SimpleXML? http://www.sloomedia.com/currency/feeds/GBP.xml Thanks, Ben. ...

Grab image url from description in rss feed using php and simplexml

I'm trying to set up a php page made up of images from 3 different RSS feeds, in 3 columns. The first feed is from a Wordpress blog, the second from an Etsy store, and the third from a Flickr feed. What I would like to do is grab the link to the images from the first 3 items in each feed. Relevant information: The Wordpress feed puts...

Query XML file with PHP to return certain bookmarks...

I have an XML file full of bookmarks from Google Bookmarks. (File: http://gist.github.com/324844) I want to pull the bookmark based on this path: xml_api_reply->bookmarks-bookmark->labels->label. So, my question is How can I use SimpleXML to grab the bookmarks that have the label Inspiration? Some bookmarks may have more than one bookm...

Simple XML Load File not working

Hi, how come this isn't working: $url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20xpath%3D%22%2F%2Fmeta%22%20and%20url%3D%22http://www.cnn.com%22&amp;format=xml&amp;diagnostics=false"; $xml = (simplexml_load_file($url)) I get multiple errors telling me the HTTP request failed. Ultimately I want to...