I have a SimpleXML object that has the following node, @attributes
. This is the result of simplexml_load_string()
from an XML string obtained from USPS.
$xml =
SimpleXMLElement Object
(
[@attributes] => Array
(
[CLASSID] => 3
)
[MailService] => Priority Mail Express 1-Day
[Rate] => 19.10
)
I realize you can do the following
$temp = $xml->attributes(); // will return object with '@attributes' note
$temp = (array)$temp; // now in array form
echo $temp['@attributes']['CLASSID']; // prints 3
$xml->{'Rate'}; // will return the rate (19.10) as a string
Is there a particular reason, why you want @attributes
for the CLASSID
? Why not jut make CLASSID
the same as MailService
or Rate
?