I can't seem to find any decent info about this on the web. Any advice?
+3
A:
I would use the DOM API that has been part of the core since 5. For an XML string $xml, you can build a DOM object with
$dom = new DOMDocument();
$dom->loadXML($xml);
Manipulate it with the rest of the DOM API, defined at http://uk.php.net/DOM
Adam Wright
2008-09-16 23:54:22
A:
And when you need to inject it back into some other DOM (like your HTML page) you can export it again using the $dom->saveXML() method. The problem however is that it also exports an xml header (it's even worse for the saveHTML version). To get rid of that use this:
$xml = $dom->saveXML();
$xml = substr( $xml, strlen( "<?xml version=\"1.0\"?>" ) );