I don't understand the $parser resource in XML parsing. I've seen it used in every example e.g.
function startElement( $parser, $name, $attrs )
And all it ever seems to get used for is tracking the depth:
depth[$parser]++;
When I print out the $parser element, all I get is:-
Resource id #1
I don't understand what it's for, or if perhaps there's a way to use it to track which node is the current one. The problem I have is that the XML structure of the file is such that there are many nodes named the same:
<page>
<page>
<page />
<page />
</page>
</page>
So I can't use the name of the node as a reference. I notice that all the PHP/XML code examples solve the slightly simpler solution of parsing an XML file whose structure is known, but in my case I don't know how many <page>s there will be.
Alternatively I've heard of the DOM alternative. Anyone used this? Is it reliable? Why is it not included with PHP in the installation?
Thanks,
Antun