我正在尝试将元素打印到此数组(下面的部分列表)。我正在尝试检索customSku元素。我一定不明白如何访问这个元素,这是我的print语句:
print $xml['Item'][0]['customSku'];
以下是print_r($xml);
:
SimpleXMLElement Object
(
[@attributes] => Array
(
[count] => 190
[offset] => 0
[limit] => 100
)
[Item] => Array
(
[0] => SimpleXMLElement Object
(
[itemID] => 242
[systemSku] => 210000000242
[defaultCost] => 23.78
[avgCost] => 23.78
[tax] => true
[archived] => false
[itemType] => default
[description] => Springfield Offset Extension Post & Pin Stainless Steel - 13" 1610413-0SS
[modelYear] => 0
[upc] => 038132915572
[ean] => SimpleXMLElement Object
(
)
[customSku] => EB-5608042
感谢您的帮助!
答案 0 :(得分:1)
使用[]
运算符用于访问节点属性,在这种情况下,这不是您想要的。
尝试以下方法:
print $xml->Item[0]->customSku;