2014-01-07 74 views
0

我將XML字符串轉換爲SimpleXMLElement對象並訪問該對象的鍵和元素。在這個過程中,我面臨着一個問題,即xml中的錨定標記無法通過對象訪問。無法從xml訪問html內容

$resultobject = simplexml_load_string($xml,null,LIBXML_NOCDATA); 

$ resultobject顯示爲:

[channel] => SimpleXMLElement Object 
    (
    [item] => Array 
     (
     [0] => 
     SimpleXMLElement Object 
      (
      [title] => "Crises and deadlocks when they occur" - www.google.com 
     ) 
    ) 
    ) 

但在嘗試訪問冠軍

echo $resultobject->channel->item[0]->title; 

獲取結果時:

「危機和死鎖時,他們發生」 -

鏈接www.google.com或任何鏈接在那裏失蹤的每個條目。這裏有什麼問題?

+1

你可以發佈你的'XML'? –

回答

0

試試這個:

echo htmlentities($resultobject->channel->item[0]->title);