DOMDocument->xinclude()
(No version information available, might be only in CVS)
DOMDocument->xinclude() — Sostituisce gli XIncludes in un oggetto DOMDocument
Descrizione
DOMDocument
int xinclude
([ int $options
] )
Sostituisce gli » XIncludes in un oggetto DOMDocument.
Nota: Poichè libxml2 risolve automaticamente le entità, quetso metodo può dare risultati inaspettati si il fil eXML incluso ha una DTD collegata.
Valori restituiti
Restituisce il numero di XIncludes nel documento.
Esempi
Example#1 Esempio di uso di DOMDocument->xinclude()
<?php
$xml = <<<EOD
<?xml version="1.0" ?>
<chapter xmlns:xi="https://www.w3.org/2001/XInclude">
<title>Books of the other guy..</title>
<para>
<xi:include href="book.xml">
<xi:fallback>
<error>xinclude: book.xml not found</error>
</xi:fallback>
</xi:include>
</para>
</chapter>
EOD;
$dom = new DOMDocument;
// output formattato
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
// carica la stringa XML definita in precedenza
$dom->loadXML($xml);
// sostituisce gli xincludes
$dom->xinclude();
echo $dom->saveXML();
?>
Il precedente esempio visualizzerà qualcosa simile a:
<?xml version="1.0"?> <chapter xmlns:xi="https://www.w3.org/2001/XInclude"> <title>Books of the other guy..</title> <para> <row xml:base="/home/didou/book.xml"> <entry>The Grapes of Wrath</entry> <entry>John Steinbeck</entry> <entry>en</entry> <entry>0140186409</entry> </row> <row xml:base="/home/didou/book.xml"> <entry>The Pearl</entry> <entry>John Steinbeck</entry> <entry>en</entry> <entry>014017737X</entry> </row> <row xml:base="/home/didou/book.xml"> <entry>Samarcande</entry> <entry>Amine Maalouf</entry> <entry>fr</entry> <entry>2253051209</entry> </row> </para> </chapter>