2013-05-07 54 views
0

前綴爲 '@' 獲取價值我有這行代碼:是在的SimpleXMLElement

print_r($item->figure->iframe); 

其中產生這樣的輸出:

SimpleXMLElement Object 
(
    [@attributes] => Array 
     (
      [height] => 288 
      [mozallowfullscreen] => true 
      [src] => http://www.hulu.com/embed.html?eid=Bq_uuy5X4KWFpYZgwa9e9g 
      [allowfullscreen] => true 
      [width] => 512 
      [frameborder] => 0 
      [scrolling] => 0 
      [webkitAllowFullScreen] => true 
     ) 

) 

我再試試這個:

var_dump($item->figure->iframe->{'@attributes'}["src"]); 

然後給我這個:

NULL 

我在做什麼錯?我想獲得src項目,爲什麼我不能得到它?

+0

使用類'SimpleXMLElement'沒有首先閱讀文檔也是錯誤的。 – Jon 2013-05-07 22:02:06

+0

此外[***看到這裏***](http://stackoverflow.com/questions/4327873/at-sign-in-simplexml-object) – phant0m 2013-05-07 22:08:03

回答