There's no simple way to access elements in PHP because it only has an event-based parser, not a tree-based one. The event based one is good but you'll have to build your own tree. Checkout the PHP documentation. You'll have to implement your own stack. I'd do something like
<article>
....
<references>
<reference type="pdf" uri="pd/test.pdf" />
</references>
Then
function addReference($type, $uri) {
insertElement("references", "reference", array($type, $uri));
}
function insertElement($into, $elem_name, $properties) {
... // parse until you find $into
// add this element to the stack
}
There is no simple way of doing this. You'll still need to write a function that generates an XML file from a stack.
Good luck. Someone needs to write an XML extension for PHP that gives us the flexibility ASP programmers have. Maybe you're the one. 🙂
Ryan