DOMDocument->xinclude()
DOMDocument->xinclude() — DOMDocument オブジェクト内の XIncludes を置換する
説明
class DOMDocument {int xinclude ( [int options] )
} このメソッドは、DOMDocument オブジェクト内の » XIncludes を置換します。
注意: include される XML ファイルに DTD が添付されている場合、libxml2 が 自動的にエンティティを解決するため、このメソッドは予期せぬ結果を 引き起こすことがあります。
パラメータ
- options
-
libxml のパラメータ。
PHP 5.1.0 および Libxml 2.6.7 以降で使用可能です。
返り値
ドキュメント内の XIncludes の数を返します。例
例 502. DOMDocument->xinclude() の例
<?php
$xml = <<<EOD
<?xml version="1.0" ?>
<chapter xmlns:xi="http://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="http://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>
DomDocument->xinclude
DomDocument->xinclude — DomDocument オブジェクトにおける XIncludes の代替
説明
int DomDocument->xinclude ( void )この関数は DomDocument オブジェクトにおける » XIncludes の代替です。
例 524. Xincludes の代替
<?php
// include.xml は以下の内容を含む :
// <child>test</child>
$xml = '<?xml version="1.0"?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="include.xml">
<xi:fallback>
<error>xinclude: include.xml not found</error>
</xi:fallback>
</xi:include>
</root>';
$domxml = domxml_open_mem($xml);
$domxml->xinclude();
echo $domxml->dump_mem();
?>
上の例の出力は以下となります。<?xml version="1.0" ?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<child>test</child>
</root> もし include.xml が存在しない場合、 次の通りとなります:
<?xml version="1.0" ?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<error>xinclude:dom.xml not found</error>
</root>
固有名詞の分類
PHP |
lchgrp sleep DomDocument->xinclude OpenSSL 関数 imagecreatefromwbmp |
Weblioに収録されているすべての辞書からDOMDocument->xinclude()を検索する場合は、下記のリンクをクリックしてください。

- DOMDocument->xinclude()のページへのリンク