DomDocument->document_element

(no version information, might be only in CVS)

DomDocument->document_element --  ルート要素ノードを返す

説明

domelement DomDocument->document_element ( void )

この関数は文章のルート要素ノードを返します。

以下の例はただ CHAPTER という名前の要素を返し表示します。 他のノード -- コメント -- は返しません。

例 1. ルート要素を取得する

<?php
include("example.inc");

if (!
$dom = domxml_open_mem($xmlstr)) {
  echo
"Error while parsing the document\n";
  exit;
}

$root = $dom->document_element();
print_r($root);
?>

上の例の出力は以下となります。

domelement Object
(
    [type] => 1
    [tagname] => chapter
    [0] => 6
    [1] => 137960648
)