PHP Wysardry
PHP Manual

PHP documentation.



Home / PHP / Manual / ...



PHP Manual
Prev Next

domxml_root

(PHP 4 >= 4.0.0)

domxml_root --  Returns root element node

Description

object domxml_root (object doc)

Warning

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change in a future release of PHP without notice. Be warned and use this function at your own risk.

domxml_root() takes one argument, an object of class "Dom document", and returns the root element node. There are actually other possible nodes like comments which are currently disregarded.

The following example returns just the element with name CHAPTER and prints it. The other root node -- the comment -- is not returned.

Example 1. Retrieving root element

<?php
$xmlstr = "<?xml version='1.0' standalone='yes'?>
<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
[ <!ENTITY sp \"spanish\">
]>
<!-- lsfj  -->
<chapter language='en'><title language='en'>Title</title>
 <para language='ge'>
  ∓amp;sp;
  <!-- comment -->
  <informaltable language='∓amp;sp;'>
   <tgroup cols='3'>
    <tbody>
     <row><entry>a1</entry><entry
morerows='1'>b1</entry><entry>c1</entry></row>
<row><entry>a2</entry><entry>c2</entry></row>
     <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
    </tbody>
   </tgroup>
  </informaltable>
 </para>
</chapter>";

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

$root = $dom->root();
/* or $root = domxml_root($dom); */
print_r($root);
?>

Prev Manual Home Next
xmltree Up domxml_add_root
Site Menu

Amazon.ca
Amazon.com
Amazon.co.uk



Most recently updated on 11 May, 2003

Home / PHP / Manual / ...



Please feel free to contact us with any comments or suggestions
PHP Manual
PHP Wysardry

This site is hosted by Spaceports