
This work is licensed under a Creative Commons License. Commercial license available upon request.
Copyright © 2001-2005 Eric Pollmann.
<div class=heading>
PHP: <a href="XMLParser.php">XMLParser.php</a>
</div>
<p tal:define="global title string:XMLParser"
tal:content="structure here/lib/cc_publicdomain">
</p>
<p>
This is a simple abstraction layer for PHP that allows XML input to be
treated as a nested array.
</p>
<p>
NOTE: THIS CODE IS OBSOLETE! Get the <b><a href="http://eric.pollmann.net/items/2007/2/2007_02_12_xmlparser/">updated version</a></b>!
</p>
<p>
Sample usage:
</p>
<pre>
require_once('XMLParser.php');
... string buffer ...
$data = '<?xml version="1.0" encoding="ISO-8859-1" ?>
<country name="usa">
<city name="mountain view">baz
<user>Jack</user>
<user>Jill</user>bam
</city>
</country>
';
$parser = new XMLParser($data, 'raw', 1);
$tree = $parser->getTree();
... file handle ...
if($fh = popen("./demo.pl", "r")) {
$parser = new XMLParser($fh, 'stream', 1);
$result = $parser->getTree();
pclose($fh);
}
... file name ...
$parser = new XMLParser('./foo.xml', 'file', 1);
$tree = $parser->getTree();
... url ...
$parser = new XMLParser('http://example.com/foo.xml', 'url', 1);
$tree = $parser->getTree();
... view output ...
// Display the array
echo '<PRE>';
print_r($tree);
echo '</PRE>';
</pre>
<p>
<a href="XMLParser.php">Download XMLParser.php</a>
</p>