2011-08-26 79 views
0

我正在做的東西與PHP的YouTube,但出現在用戶圖片部分的XML文件,不會出現在輸出中。Youtube SimpleXMLElement prob!em

代碼:

$feedURL = 'http://gdata.youtube.com/feeds/api/users/davidguetta'; 
$sxml = simplexml_load_file($feedURL); 

輸出:

SimpleXMLElement Object 
(
    [id] => http://gdata.youtube.com/feeds/api/users/davidguetta 
    [published] => 2006-07-26T12:05:23.000-07:00 
    [updated] => 2011-08-26T04:34:26.000-07:00 
    [category] => Array 
     (
      [0] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [scheme] => http://schemas.google.com/g/2005#kind 
          [term] => http://gdata.youtube.com/schemas/2007#userProfile 
         ) 

       ) 

      [1] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [scheme] => http://gdata.youtube.com/schemas/2007/channeltypes.cat 
          [term] => Musician 
         ) 

       ) 

     ) 

    [title] => davidguetta Channel 
    [link] => Array 
     (
      [0] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [rel] => http://gdata.youtube.com/schemas/2007#user.vlog 
          [type] => application/atom+xml 
          [href] => http://gdata.youtube.com/feeds/api/playlists/18F8D522B6C5D32C 
         ) 

       ) 

      [1] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [rel] => related 
          [type] => text/html 
          [href] => http://www.davidguetta.com 
         ) 

       ) 

      [2] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [rel] => alternate 
          [type] => text/html 
          [href] => http://www.youtube.com/profile?user=davidguetta 
         ) 

       ) 

      [3] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [rel] => self 
          [type] => application/atom+xml 
          [href] => http://gdata.youtube.com/feeds/api/users/davidguetta 
         ) 

       ) 

     ) 

    [author] => SimpleXMLElement Object 
     (
      [name] => davidguetta 
      [uri] => http://gdata.youtube.com/feeds/api/users/davidguetta 
     ) 

) 

爲什麼不輸出以下?

<media:thumbnail url='http://i2.ytimg.com/i/uYZ-sFza5K_3GF0LyQAxjg/1.jpg'/> 

回答

0

看起來像SimpleXMLElement在標籤名中被':'弄糊塗了。您應該使用代替。

+0

我知道。有太多的文件,我想做一些簡單而簡單的事情。那麼,如何解決這個問題呢? –

+1

在這種情況下,您可能會發現使用JSON數據更容易:http://gdata.youtube.com/feeds/api/users/davidguetta?alt=json – mjhm

+0

感謝mjhm(:以前嘗試過,但可能我寫了錯誤的鏈接json。現在,再次謝謝你... –