Skip to content

Instantly share code, notes, and snippets.

@shulard
Last active May 2, 2016 14:07
Show Gist options
  • Save shulard/cb109c72ddb552ffedb2acee5b71587b to your computer and use it in GitHub Desktop.
Save shulard/cb109c72ddb552ffedb2acee5b71587b to your computer and use it in GitHub Desktop.
How to use the `xi:include` tag in XML files...
<?xml version='1.0'?>
<disclaimer>
<p>The opinions represented herein represent those of the individual
and should not be interpreted as official policy endorsed by this
organization.</p>
</disclaimer>
<?xml version="1.0"?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>120 Mz is adequate for an average home user.</p>
<disclaimer>
<p>The opinions represented herein represent those of the individual
and should not be interpreted as official policy endorsed by this
organization.</p>
</disclaimer>
</document>
<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
<p>120 Mz is adequate for an average home user.</p>
<xi:include href="disclaimer.xml"/>
</document>
<?php
$doc = new DOMDocument();
$doc->load('root.xml');
$doc->xinclude();
echo $doc->saveXML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment