1

如何遍历 RSS 提要中的多个对象(见下文)并使用 simplexml_load 对象处理仅获取两个不同数组中的title和?videoid

包含类似变量的对象的相关 RSS 提要:

object(SimpleXMLElement)[1]
 public 'id' => string 'tag:youtube.com,2008:videos' (length=27)
public 'updated' => string '2012-11-15T19:57:00.097Z' (length=24)
public 'category' => 
object(SimpleXMLElement)[2]
  public '@attributes' => 
    array
      'scheme' => string 'http://schemas.google.com/g/2005#kind' (length=37)
      'term' => string 'http://gdata.youtube.com/schemas/2007#video' (length=43)
public 'title' => string 'Videos matching: mitar miric opasnica' (length=37)
public 'logo' => string 'http://www.youtube.com/img/pic_youtubelogo_123x63.gif'   
(length=53)
public 'link' => 
array
  0 => 
    object(SimpleXMLElement)[3]
      public '@attributes' => 
        array
          ...
  1 => 
    object(SimpleXMLElement)[4]
      public '@attributes' => 
        array
          ...
  2 => 
    object(SimpleXMLElement)[5]
      public '@attributes' => 
        array
          ...
  3 => 
    object(SimpleXMLElement)[6]
      public '@attributes' => 
        array
          ...
  4 => 
    object(SimpleXMLElement)[7]
      public '@attributes' => 
        array
          ...
  5 => 
    object(SimpleXMLElement)[8]
      public '@attributes' => 
        array
          ...
public 'author' => 
object(SimpleXMLElement)[9]
  public 'name' => string 'YouTube' (length=7)
  public 'uri' => string 'http://www.youtube.com/' (length=23)
public 'generator' => string 'YouTube data API' (length=16)
public 'entry' => 
 array
  0 => 
    object(SimpleXMLElement)[10]
      public 'id' => string 'tag:youtube.com,2008:video:iCm1ohCJHhk' (length=38)
      public 'published' => string '2008-11-28T00:20:17.000Z' (length=24)
      public 'updated' => string '2011-11-14T10:56:22.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'Mitar Miric & Zilhad XXL Band - Opasnica' (length=40)
      public 'content' => 
        object(SimpleXMLElement)[18]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[24]
          ...
  1 => 
    object(SimpleXMLElement)[11]
      public 'id' => string 'tag:youtube.com,2008:video:O3Wsm3GbQcg' (length=38)
      public 'published' => string '2008-06-07T21:03:43.000Z' (length=24)
      public 'updated' => string '2012-09-26T11:09:20.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'Mitar Miric - Za Koga Cuvas (DM SAT)' (length=36)
      public 'content' => 
        object(SimpleXMLElement)[27]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[34]
          ...
  2 => 
    object(SimpleXMLElement)[12]
      public 'id' => string 'tag:youtube.com,2008:video:rv5VVJajGsw' (length=38)
      public 'published' => string '2007-09-09T23:04:02.000Z' (length=24)
      public 'updated' => string '2012-11-12T12:51:23.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'Mitar Miric - Ja ne zivim ovde' (length=30)
      public 'content' => 
        object(SimpleXMLElement)[37]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[44]
          ...
  3 => 
    object(SimpleXMLElement)[13]
      public 'id' => string 'tag:youtube.com,2008:video:lfi15eLXzuc' (length=38)
      public 'published' => string '2006-04-14T23:45:01.000Z' (length=24)
      public 'updated' => string '2012-11-04T16:37:57.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'Mitar Miric - Opasnica (by Iggyy)' (length=33)
      public 'content' => 
        object(SimpleXMLElement)[47]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[53]
          ...
  4 => 
    object(SimpleXMLElement)[14]
      public 'id' => string 'tag:youtube.com,2008:video:ctM4mHsGx-0' (length=38)
      public 'published' => string '2011-07-26T23:28:06.000Z' (length=24)
      public 'updated' => string '2012-07-07T22:27:19.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'Cvaka Cvak - Palis Palis Mene' (length=29)
      public 'content' => 
        object(SimpleXMLElement)[56]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[63]
          ...
  5 => 
    object(SimpleXMLElement)[15]
      public 'id' => string 'tag:youtube.com,2008:video:LqAtJcWAyJ8' (length=38)
      public 'published' => string '2008-07-10T10:39:13.000Z' (length=24)
      public 'updated' => string '2012-04-22T11:05:28.000Z' (length=24)
      public 'category' => 
        array
          ...
      public 'title' => string 'OPASNICE!!!!!' (length=13)
      public 'content' => 
        object(SimpleXMLElement)[66]
          ...
      public 'link' => 
        array
          ...
      public 'author' => 
        object(SimpleXMLElement)[72]
          ...
4

0 回答 0