2012-07-10 7 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; 

这将工作。请享用。