DOMDocument->xinclude()
(No version information available, might be only in CVS)
DOMDocument->xinclude() — DOMDocument オブジェクト内㮠XIncludes ã‚’ç½®æ›ã™ã‚‹
説明
DOMDocument
int xinclude
([ int $options
] )
ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ã€DOMDocument オブジェクト内㮠» XIncludes ã‚’ç½®æ›ã—ã¾ã™ã€‚
注æ„: include ã•れる XML ファイル㫠DTD ãŒæ·»ä»˜ã•れã¦ã„ã‚‹å ´åˆã€libxml2 ㌠自動的ã«ã‚¨ãƒ³ãƒ†ã‚£ãƒ†ã‚£ã‚’解決ã™ã‚‹ãŸã‚ã€ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯äºˆæœŸã›ã¬çµæžœã‚’ 引ãèµ·ã“ã™ã“ã¨ãŒã‚りã¾ã™ã€‚
パラメータ
- options
-
libxml ã®ãƒ‘ラメータ。 PHP 5.1.0 ãŠã‚ˆã³ Libxml 2.6.7 以é™ã§ä½¿ç”¨å¯èƒ½ã§ã™ã€‚
返り値
ドã‚ュメント内㮠XIncludes ã®æ•°ã‚’è¿”ã—ã¾ã™ã€‚
例
Example#1 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;
// 見ãŸç›®ã‚’ãれã„ã«ã—ã¾ã™
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
// 上ã§å®šç¾©ã—㟠XML æ–‡å—列をèªã¿è¾¼ã¿ã¾ã™
$dom->loadXML($xml);
// xincludes ã‚’ç½®æ›ã—ã¾ã™
$dom->xinclude();
echo $dom->saveXML();
?>
上ã®ä¾‹ã®å‡ºåŠ›ã¯ã€ãŸã¨ãˆã° 以下ã®ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚
<?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>