The Note You're Voting On
mail at kleineedv dot de ¶ 16 years ago
I had a problem with simplexml reading nodes from an xml file. It always return an SimpleXML-Object but not the text inside the node.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<Test>
<Id>123</Id>
</Test>
Reading this xml into a variable called $xml and then doing the following
<?php
$myId = $xml->Id;
?>
Did not return 123 in $myId, but instead I got a SimpleXMLElement Object.
The solution is simple, when you know it. Use explicit string conversion.
<?php
$myId = (string)$xml->Id;
?>