I have an xml document which I am trying to access a value of a certain child element using xpath.
$xml = new SimpleXMLElement($url,null,true);
$value = $xml->xpath("/xxx/yyy/zzz");
when I use:
print_r($value);
ouputs the following:
Array
(
[0] => SimpleXMLElement Object
(
[0] => 1003.39
)
)
I can access the value of the SimpleXMLElement Object by doing the following:
echo $value[0]
however I don't want to store the SimpleXMLElement Object within $value. I want to store the objects value within $value.
e.g. I want to use:
echo $value
to return
1003.39
What do I need to change in
$value = $xml->xpath("/xxx/yyy/zzz");
in order to return the value, not the object?
p.s. If I cast to a string using (string), then my print_r or echo $value prints "Array" instead of the value!