Reputation: 7930
As simple as the sun light:
$xml = new SimpleXMLElement('<string>-2|-2|635705730515209906|7F2ShUrAQFJmvxTxVgkm2yjghWorOaZe/g==</string>');
var_dump($xml->{"string"});die();
It prints:
object(SimpleXMLElement)#67 (0) { }
I would expect the content of "string" node... If I do
var_dump($xml);
I get:
object(SimpleXMLElement)#66 (1) { [0]=> string(61) "-2|-2|635705730515209906|7F2ShUrAQFJmvxTxVgkm2yjghWorOaZe/g==" }
But how to get the node "string" ?
Upvotes: 0
Views: 699
Reputation: 146390
The top level element (aka root node) is always implicit. You also need to cast to a scalar type or you'll get the object itself. Combined:
$xml = new SimpleXMLElement('<string>-2|-2|635705730515209906|7F2ShUrAQFJmvxTxVgkm2yjghWorOaZe/g==</string>');
var_dump((string)$xml);
Upvotes: 2