我想從xml字符串中獲取信息並查看其中的子節點。我使用:simplexml_load_string和子節點
'Title' => $current->AttributeSets->children('ns2')->ItemAttributes->Title,
在數組,其中$當前
$current = $parsed_xml->ListMatchingProductsResponse->ListMatchingProductsResult->Products->Product;
命名空間NS2和孩子們ItemAttributes中和標題。當我運行這個時,我不知道標題應該在哪裏。下面是我運行腳本時的響應:
SimpleXMLElement Object()
任何人都可以指向正確的方向嗎?我看了其他的帖子,試圖用他們的例子,但他們不適合我。 這裏是XML:
<?xml version="1.0"?>
<ListMatchingProductsResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<ListMatchingProductsResult>
<Products xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<Product>
<AttributeSets>
<ns2:ItemAttributes xml:lang="en-US">
<ns2:Title>JavaScript: The Missing Manual</ns2:Title>
您需要發佈您的XML。 – nickb 2012-07-10 17:34:30