PHP5 - Reading XML nodeValue reads object id#'s
Posted: Mon Feb 05, 2007 11:38 am
Hey All,
This may be simple. I'd like to get my output to read the nodeValue of my requested tag ('name').
Why am I getting an object id# and how can I get it to print what the nodeValue of my node is.
example xml file:
I looked and even copied the DOM getElementsByTagName function
http://us3.php.net/manual/en/function.d ... agname.php
and their response is readable. The difference is I want to read the value of the node and they
are reading the attribute of the node.
prints:
expected:
Lastly is there a place to look for object id# references? So I know what the object id # is trying to tell me?
ie... Object ID#1 is a string value or something like that? Just curious.
thanks,
sky
This may be simple. I'd like to get my output to read the nodeValue of my requested tag ('name').
Why am I getting an object id# and how can I get it to print what the nodeValue of my node is.
example xml file:
Code: Select all
<neighborhood>
<House>
<name> Toms Jones </name>
</House>
<House>
<name> Jennifer Reed </name>
</House>
</neighborhood>http://us3.php.net/manual/en/function.d ... agname.php
and their response is readable. The difference is I want to read the value of the node and they
are reading the attribute of the node.
Code: Select all
<?php
$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load('thexml.xml');
$params = $dom->getElementsByTagName('House');
foreach ($params as $param) {
echo $param->getElementsByTagName('name').'<br />';
/* also tried
echo $param->getElementsByTagName('name')->nodeValue.'<br />';
echo $param->getElementsByTagName('name')->nodeName.'<br />';
*/
}
?>Code: Select all
Object id #5
Object id #3expected:
Code: Select all
Tom Jones
Jennifer ReedLastly is there a place to look for object id# references? So I know what the object id # is trying to tell me?
ie... Object ID#1 is a string value or something like that? Just curious.
thanks,
sky