2012-07-10 10 views
0

所以我有這樣的XML的XMLReader中的所有元素不讀請求

<entry> 
<id>ABC123</id> 
<title type="text">title </title> 
<author xmlns="http://www.w3.org/2005/Atom"> 
    <name>test.com</name> 
</author> 
<link rel="self" href="http://www.test.com/asdasd.html"/> 
<updated>2012-07-04T06:12:15.337</updated> 
<content type="xml"> 
    <listing systemId="thesystemid" url="www.myurl.com"> 
     <description> 
      This is a description 
     </description> 
    </listing> 
</content> 
</entry> 

我使用的XMLReader與此代碼,我用這個數據拉:

$url = $product->content->listing['url']; 
$id = $product->id; 
$name = $product->title; 
$desc = $product->content->listing->description; 

一切在被拉完美除了$遞減

$產品已經被設置爲「進入」

我做不到看到爲什麼,有什麼想法?

錯誤是

Notice: Trying to get property of non-object in...... 

乾杯

+0

你收到任何錯誤信息? – 2012-07-10 09:57:48

+0

向帖子中添加了錯誤:) – Franco 2012-07-10 10:00:18

+0

我認爲某些元素的描述缺失..你可以檢查一下嗎? – 2012-07-10 10:04:06

回答

1

檢查這個

$aa= '<entry> 
    <id>ABC123</id> 
    <title type="text">title </title> 
    <author xmlns="http://www.w3.org/2005/Atom"> 
    <name>test.com</name> 
    </author> 
    <link rel="self" href="http://www.test.com/asdasd.html"/> 
    <updated>2012-07-04T06:12:15.337</updated> 
    <content type="xml"> 
    <listing systemId="thesystemid" url="www.myurl.com"> 
    <description> 
     This is a description 
    </description> 
    </listing> 
    </content> 
    </entry>'; 
    $xml = simplexml_load_string($aa); 
    echo $xml->content->listing->description; 

這將工作。請享用。