On 1 Dec 2006 14:37:11 -0800, "yawnmoth" <te*******@yahoo.comwrote:
>I'm trying to mess around with PHP5's DOM functions and have run into
something that confuses me:
<?php
$dom = new DOMDocument();
$dom->loadHTML('<html></html>');
echo $dom->childNodes->length;
?>
Why is the output 2? Shouldn't it be 1?
<?php
$dom = new DOMDocument();
$dom->loadHTML('<html></html>');
print get_class($dom->childNodes->item(0)) . "<br>";
print get_class($dom->childNodes->item(1)) . "<br>";
print htmlspecialchars($dom->saveHTML());
?>
DOMDocumentType
DOMElement
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd"<html></html>
--
Andy Hassall ::
an**@andyh.co.uk ::
http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool