I fear that this is a really stupid question but I am really stuck after trying a load of combinations for the last 2 hours. I am trying to pull the NAME out of the XML file
My XML file:
<?xml version="1.0"?> <userdata> <name>John</name> </userdata>
My php:
$doc = new DOMDocument(); $doc -> load( "thefile.xml" ); $thename = $doc -> getElementsByTagName( "name" ); $myname= $thename -> getElementsByTagName("name") -> item(0) -> nodeValue;
The Error:
Catchable fatal error: Object of class DOMElement could not be converted to string in phpreader.php
I have tried
$myname= $thename -> getElementsByTagName("name") -> item(0) ; $myname= $doc -> getElementsByTagName("name") -> item(0) -> nodeValue; $myname= $doc -> getElementsByTagName("name") -> item(0) ;
but all fail. Guess I have tried just about every combination except the correct one :(