I'm afraid this is a really stupid question, but I really got stuck after trying to load combinations in the last 2 hours. I am trying to pull NAME from an 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;
Error:
Catchable fatal error: Object of class DOMElement could not be converted to string in phpreader.php
I tried
$myname= $thename -> getElementsByTagName("name") -> item(0) ;
$myname= $doc -> getElementsByTagName("name") -> item(0) -> nodeValue;
$myname= $doc -> getElementsByTagName("name") -> item(0) ;
but everything is failing. I think I tried almost every combination except the correct one :(
Morph source
share