$tmp2 = '<?xml version="1.0"?><RWResponse><RESPONSE><DATA><HEADER><COLUMN>interval</COLUMN><COLUMN>name</COLUMN></HEADER></DATA></RESPONSE></RWResponse>';
$xml = simplexml_load_string($tmp2);
echo $xml->RESPONSE->DATA->HEADER->COLUMN[0];
The above won’t output anything, even though a var_dump is sucessful:
object(SimpleXMLElement)#2 (1) {
["RESPONSE"]=>
object(SimpleXMLElement)#3 (1) {
["DATA"]=>
object(SimpleXMLElement)#4 (1) {
["HEADER"]=>
object(SimpleXMLElement)#5 (1) {
["COLUMN"]=>
array(2) {
[0]=>
string(8) "interval"
[1]=>
string(13) "creative_name"
}
}
}
}
}
Thanks
This is because SimpleXML requires exact typecasting or you’ll get riddiculous things happening like this – var_dump will output what you want, echo won’t. You always need to do this, there are even worse bugs, like
echo ceil($simplexml->someNumber)will output7if the number is for example7.85and so on.Try instead: