XML XInclude does not display correctly?
题
I am testing XML.XInclude following its structure guide:
I have a child1.xml file:
<?xml version="1.0"?>
<child1>
<config>
</config>
</child1>
a child2.xml file:
<?xml version="1.0"?>
<child2>
<config>
</config>
</child2>
and parent.xml file:
<?xml version="1.0"?>
<config xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="xml" href="child1.xml"/>
<xi:include parse="xml" href="child2.xml"/>
</config>
However, when I open parent.xml in Internet Explorer, the child1.xml and child2.xml are not merged inside the parent.xml. I expect that the contents of child1.xml and child2.xml are shown in parent.xml but it does not. I just see this with parent.xml:
<?xml version="1.0" ?>
- <config xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="xml" href="child1.xml" />
<xi:include parse="xml" href="child2.xml" />
</config>
Did I do something wrong or using XInclude will not show the include files?
Thanks in advance.
解决方案
Internet Explorer doesn't have any support for XInclude. Nor does any other browser I can think of. You need to use an XInclude processor. E.g. if you had it parent.xml loaded into a PHP DOMDocument
then you could call its xinclude()
method and it would process the includes.