PHP: DomDocument->document_element - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DomDocument->dump_file DomDocument->doctype

Last updated: Sat, 27 Jan 2007

view this page in

# DomDocument->document_element

(no version information, might be only in CVS)

DomDocument->document_element -- Returns root element node

## Описание

domelement DomDocument->document_element ( void )

This function returns the root element node of a document.

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

Пример 1. Retrieving root element

`<?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
    )

add a note User Contributed Notes
DomDocument->document_element
filipp at mac dot com
30-Dec-2006 02:29
`as of PHP 5 (tested with 5.1.4), remember to use documentElement instead. As in:
$dom = new DomDocument ();
$dom -> load ('file.xml');
$newEl = $dom -> createElement ('newEl');
$dom -> documentElement -> appendChild ($newEl);`
add a note
DomDocument->dump_file DomDocument->doctype

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST