[UPHPU] beginner to DOM library

Richard K Miller richardkmiller at gmail.com
Wed Nov 8 10:39:55 MST 2006


I'm trying to get acquainted with the PHP DOM library (php.net/dom)  
available in PHP5.  Any idea why I don't get more meaningful output  
from this code?

<?php

$doc = new DOMDocument;
$doc->loadXML('<?xml version="1.0" encoding="iso-8859-1" ? 
 ><foo><bar>hello world</bar></foo>');
print_r($doc);

$xpath = new DOMXPath($doc);
print_r($xpath);

$nodes = $xpath->query("//foo");
print_r($nodes);

foreach($nodes as $node)
	print_r($node);

?>

OUTPUT:

DOMDocument Object
(
)
DOMXPath Object
(
)
DOMNodeList Object
(
)
DOMElement Object
(
)

I was hoping the output would include various nodes in the document.   
Maybe PHP is masking the values from print_r()?

Richard




More information about the UPHPU mailing list