I'm trying to read in an attribute of an XML object in PHP and cannot get the value.
The XML looks like this:
<TransResult>
<ResultCode tc="5">Failure</ResultCode>
<ResultInfo>
<ResultInfoCode tc="200"/>
<ResultInfoDesc>Product not available</ResultInfoDesc>
I've tried:
$resultInfoCode=$xml->TransResult->ResultInfo->ResultInfoCode;
$resultInfoCode=$xml->TransResult->ResultInfo->ResultInfoCode['tc'];
And several other variations of those but it either returns null or throws an error.
Any help is greatly appreciated.
TransResultis the root element and must not be part of the path. Have a look at my example.