Possible Duplicate:
How to get an attribute with SimpleXML?如果節點具有屬性,如何從xml檢索值?
我怎樣才能得到高度,長度,重量和寬度的值?因爲它具有屬性呢?在其他值中,我沒有檢索它的問題,只是這個值有屬性。
注:高度,長度,重量和寬度的部分僅是問題
這裏是我如何找回它:
$from_amazon = array(
'asin' => $item->ASIN,
'product_name'
=> $item->ItemAttributes->Title,
'image' => $item->SmallImage->URL,
'price' => $item->ItemAttributes->ListPrice->FormattedPrice,
'product_description'
=> $item->EditorialReviews->EditorialReview->Content,
'category' => $item->ItemAttributes->ProductGroup,
'weight' => $item->ItemAttributes->PackageDimensions->Weight
);
我不明白呢? :( –
再試一次,看看下面答案中代碼行的變化如果你想了解更多,你應該閱讀關於simplexml的手冊,它有一些基本的例子:http://php.net/manual /en/simplexml.examples-basic.php,其中包含你需要知道的所有東西,特別是* Example#5使用屬性*有你要找的東西 – hakre
在我的回覆中,權重值就像這個「weight」:{ @attributes「:{」Units「:」百分之一磅「},」0「:」420「}} –