DOMDocument->xinclude()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > PHP関数リファレンス > DOMDocument->xinclude()の意味・解説 

DOMDocument->xinclude()

(No version information available, might be only in CVS)
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

(No version information available, might be only in CVS)
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>




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DOMDocument->xinclude()」の関連用語

DOMDocument->xinclude()のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DOMDocument->xinclude()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
PHP Documentation GroupPHP Documentation Group
Copyright © 1997 - 2024 by the PHP Documentation Group.

©2024 GRAS Group, Inc.RSS