2012-01-22 34 views
0

誰かがこのXMLフィードの 'item'部分にアクセスする方法を教えてください。ここにファイルのVAR_DUMPがあります。イムGoogleからのフィードを引っ張ってsimplexml_load_string使用が、どのように私はとても好きですが、「アイテム」メンバ変数にアクセスできるように見えます「アイテム」内容アクセスxmlオブジェクトの後にPHP解析

object(SimpleXMLElement)[1] 
    public '@attributes' => 
    array 
     'version' => string '2.0' (length=3) 
    public 'channel' => 
    object(SimpleXMLElement)[2] 
     public 'generator' => string 'NFE/1.0' (length=7) 
     public 'title' => string 'running barefoot - Google News' (length=30) 
     public 'link' => string 'http://news.google.com/news?pz=1&ned=us&hl=en&q=running+barefoot' (length=64) 
     public 'language' => string 'en' (length=2) 
     public 'webMaster' => string '[email protected]' (length=24) 
     public 'copyright' => string '©2012 Google' (length=17) 
     public 'pubDate' => string 'Sun, 22 Jan 2012 04:38:34 GMT' (length=29) 
     public 'lastBuildDate' => string 'Sun, 22 Jan 2012 04:38:34 GMT' (length=29) 
     public 'image' => 
     object(SimpleXMLElement)[3] 
      public 'title' => string 'running barefoot - Google News' (length=30) 
      public 'url' => string 'http://www.gstatic.com/news/img/logo/en_us/news.gif' (length=51) 
      public 'link' => string 'http://news.google.com/news?pz=1&ned=us&hl=en&q=running+barefoot' (length=64) 
     public 'item' => 
     array 
      0 => 
      object(SimpleXMLElement)[4] 
       ... 
      1 => 
      object(SimpleXMLElement)[5] 
       ... 
      2 => 
      object(SimpleXMLElement)[6] 
       ... 
      3 => 
      object(SimpleXMLElement)[7] 
       ... 
      4 => 
      object(SimpleXMLElement)[8] 
       ... 
      5 => 
      object(SimpleXMLElement)[9] 
       ... 
      6 => 
      object(SimpleXMLElement)[10] 
       ... 
      7 => 
      object(SimpleXMLElement)[11] 
       ... 
      8 => 
      object(SimpleXMLElement)[12] 
       ... 
      9 => 
      object(SimpleXMLElement)[13] 
       ... 
     public 'description' => string 'Google News' (length=11) 

答えて

1

はあなたを持っていますあなたが尋ねる前に検索しようとした? RSSフィードを解析するチュートリアルがたくさんあります。 - for example

foreach($yourObject->channel->item as $item) 
{ 
    echo $item->title; 
    echo $item->link; 
} 
+0

ありがとうございます。私は探していましたが少し助けが必要です。 – Cjueden