2011-12-14 18 views
0

我試圖將一個元素打印到此數組(下面的部分列表)。我正在嘗試檢索customSku元素。我一定不知道如何訪問這個元素,這是我的print語句:PHP在用simplexml_load_file檢索到的XML文檔中訪問數組的emlelments

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

您可以張貼問題 – abcde123483 2011-12-14 19:36:43

回答

1

使用[]運算符用於訪問節點屬性,在這種情況下這不是您想要的。

嘗試以下操作:

print $xml->Item[0]->customSku; 
+0

實際的XML文件,XML的$>項目[0] - > customSku – jbnunn 2011-12-14 19:41:49

相關問題