Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- From: list-support@xxxxxxxxxxxx (Ben Roberts)
- Date: Wed, 28 Feb 2007 20:24:51 +0000
Rob wrote:
Ben Roberts wrote:
I'm trying to get the SimpleXML extension to read an XML file and process the XInclude statements within the XML file.
The SimpleXML docs state that libxml options may be specified using the predefined constants that are available when PHP is compiled with libxml support (as it is when you use SimpleXML).
http://uk2.php.net/manual/en/function.simplexml-element-construct.php
LIBMLXML_XINLCUDE currently only works with XMLReader.
You would need to import your doc to DOM and then processes the xinclude:
$xml_file = './master.xml';
$xml = new SimpleXMLElement($xml_file, 0, true);
$dom = dom_import_simplexml($xml);
$dom->ownerDocument->xinclude();
print_r($xml);
Rob
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);
I have to convert it back to the SimpleXML object as I have an existing application that relies on the SimpleXML structure.
Is it likely that this will be supported directly by SimpleXML in future versions of PHP?
Ben
.
- Follow-Ups:
- Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- From: Rob Richards
- Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- References:
- SimpleXML & libxml options (XInclude)
- From: Ben Roberts
- Re: SimpleXML & libxml options (XInclude)
- From: Rob
- SimpleXML & libxml options (XInclude)
- Prev by Date: Re: [PHP] Combining sound files
- Next by Date: Re: [PHP] echo text - anti-spam-spider measure
- Previous by thread: Re: SimpleXML & libxml options (XInclude)
- Next by thread: Re: [PHP] Re: SimpleXML & libxml options (XInclude)
- Index(es):
Relevant Pages
|