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“}} –