dom - Does a PHP supports recursively processing of xi:include elements?

Solution:
The only thing I can find missing is that you have to make sure that in both the index.xml and the sitemap.xml, you need to have the xi namespace declared in the document, so with
index.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xi="http://www.w3.org/2001/XInclude">
<url>
<loc>/privacy/</loc>
<query>/?template=home&content=home</query>
</url>
<xi:include href="legal/sitemap.xml" xpointer="xpointer(//urlset/*)"/>
</urlset>
sitemap.xml
<urlset xmlns:xi="http://www.w3.org/2001/XInclude">
<url>
<loc>/cookies/</loc>
<query>/?template=page&content=cookies</query>
<lastmod><xi:include href="cookies.xml" xpointer="xpointer(//*[1]/datePublished/text())"/></lastmod>
</url>
</urlset>
cookies.xml
<?xml version="1.0" encoding="UTF-8"?>
<section xml:id="php" class="page">
<title>Cookies</title>
<datePublished>2018-11-28T12:02:41Z</datePublished>
</section>
and the code...
$xml = new DOMDocument();
$xml->load("index.xml");
$xml->xinclude();
echo $xml->saveXML();
you end up with
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xi="http://www.w3.org/2001/XInclude">
<url>
<loc>/privacy/</loc>
<query>/?template=home&content=home</query>
</url>
<url xmlns:xi="http://www.w3.org/2001/XInclude" xml:base="legal/sitemap.xml">
<loc>/cookies/</loc>
<query>/?template=page&content=cookies</query>
<lastmod>2018-11-28T12:02:41Z</lastmod>
</url>
</urlset>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: videoxxx
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.