我有一个SimpleXML对象,它具有以下节点@attributes
。这是从USPS获得的XML字符串中的simplexml_load_string()
的结果。XML:什么是“@attributes”节点
$xml =
SimpleXMLElement Object
(
[@attributes] => Array
(
[CLASSID] => 3
)
[MailService] => Priority Mail Express 1-Day
[Rate] => 19.10
)
我知道你可以做以下
$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
有什么特别的原因,你为什么要@attributes
为CLASSID
?为什么不突出使CLASSID
与MailService
或Rate
相同?
对不起,我澄清了我的问题。我不问如何访问它。我在问XML对象的结构背后的原因。如有必要,请删除。 – musicliftsme
XML的格式不是我们可以回答的问题,你必须问USPS。 –
^,好的,那是真的。我注意到USPS奇怪地处理数据。 – musicliftsme