Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
682
DOMDocument Function xinclude
PHP Version: (No version information might be only in CVS. I have used this function
in PHP5)
DOM: W3C
DOM Level 1
Description
This function substitutes XIncludes
in a DomDocument Object by actual content referred by
xinclude.
Usage:
intDOMDocument->xinclude ( void )
Substitutes
XIncludes in a DOMDocument
Object.
PHP
Code:
<?php
$xmlstr = <<<XML
<?xml version="1.0"
encoding="UTF-8"?>
<root
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:includehref="xml_files/xinclude.xml">
<xi:fallback>
<error>xinclude: xinclude.xml not
found</error>
</xi:fallback>
</xi:include>
</root>
XML;
$dom = new domDocument;
//load
the XML string into the DOM
$dom->loadXML($xmlstr);
//replca the xinclude function
$dom->xinclude();
//echo
out the content
echo "<PRE>";
echohtmlentities($dom->saveXML());
echo "</PRE>";
?>
Content
of xinclude.xml(ensure that this file is accessible by PHP code otherwise
you will get error):