Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- From: rrichards@xxxxxxxxxxxxxxxx (Rob Richards)
- Date: Wed, 28 Feb 2007 15:31:42 -0500
Ben Roberts wrote:
Thanks Rob. That works. And it appears to work flawlessly if you subsequently convert it back to a SimpleXML object too: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.
$xml = new SimpleXMLElement($xml_file, 0, true);
$dom = dom_import_simplexml($xml);
$dom->ownerDocument->xinclude();
$xml = simplexml_import_dom($dom);
Dump($xml);
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
.
- Follow-Ups:
- Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- From: Ben Roberts
- Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- References:
- SimpleXML & libxml options (XInclude)
- From: Ben Roberts
- Re: SimpleXML & libxml options (XInclude)
- From: Rob
- Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- From: Ben Roberts
- SimpleXML & libxml options (XInclude)
- Prev by Date: Re: [PHP] echo text - anti-spam-spider measure
- Next by Date: Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- Previous by thread: Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- Next by thread: Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- Index(es):
Relevant Pages
|