Ben Roberts wrote:
Thanks Rob. That works. And it appears to work flawlessly if you
subsequently convert it back to a SimpleXML object too:
$xml = new SimpleXMLElement($xml_file, 0, true);
$dom = dom_import_simplexml($xml);
$dom->ownerDocument->xinclude();
$xml = simplexml_import_dom($dom);
Dump($xml);
No need to even do that. The document is the same document (zero copy
which is why going back and forth is efficient), so when its changed by
the xinclude call, it is reflected in $xml already. Only reason you
would need to do conversions back and forth is if you need specific
nodes that might have been added/changed by the other extension. Here
you are using the same root element and dont have to worry about losing
any child references you might already have, so its a wasted call.
Is it likely that this will be supported directly by SimpleXML in
future versions of PHP?
Unless the libxml2 parser in SimpleXML can take advantage of the option,
an XInclude method is not going to be added to SimpleXML. For things
like that, and full XPath support, etc.., you need to interop with DOM
so SimpleXML can be kept simple.
Rob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php