<?php
$xml = simplexml_load_file('foo.xml');
print_r($xml);
?>
works fine, unless the XML file contains tags with colons, e.g.:
<rs:data>
In this case, I get an empty object. What am I missing?
I need to parse third-party XML files. I believe it's ADO XML:
http://www.devarticles.com/c/a/XML/Displaying-ADO-Retrieved-Data-with-XML-Islands/2/
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
For the records: I finally discarded SimpleXML. It's only simple when
you don't have namespaces.
I tried the XMLReader extension with sample code taken from a user
note in the PHP manual and I got it working in a few minutes, although
the code is not intuitive at all. I also tried the DOM extension and
the results were similar, but the code was slightly more intuitive.
Finally, I found a PHP port of JavaScript's jQuery library: phpQuery
[1]. I parsed my XML with a few lines of code and I can even
understand them :) Using such library is probably an overkill but it
was quick and easy.
[1] http://code.google.com/p/phpquery/