Some days ago Daniele, a friend of mine, point my attention to an opensource project hosted on sourceforge that is very interesting for PHP/Flash guys 🙂
This module permit to do an xml parsing, in PHP, using a dom xml in the same way we already do in flash.
Here a little example i made using this class:
<? // include the php module include('lib.xml.inc.php'); // load an external xml source $test = new XML('test.xml'); // make a simple parsing, in AS style ;) $childs = $test->firstChild->childNodes; for($a = 0; $a < count($childs); $a++){ echo "nodeName " . $childs[$a]->nodeName . "<br />"; echo "nodeValue " . $childs[$a]->firstChild->nodeValue . "<br />"; } ?>
as you can see, we’re already familiar with firstChild, nodeName, nodeValue… etc..
I always hate the PHP SAX parser, and always always prefer a dom xml parser, much more simple to create and to read.