我試圖解析這個XML飼料使用simplexml_load_file解析[@屬性] =>陣列
[0] => SimpleXMLElement Object
(
[title] => Johannesburg in November
[link] => SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => alternate
[type] => text/html
[href] => http://www.tompeters.com/dispatches/012120.php?rss=1
)
)
[id] => tag:www.tompeters.com,2011://2.12120
[published] => 2011-09-08T14:03:23Z
[updated] => 2011-09-08T14:11:49Z
[summary] => Tom will be giving a day-long presentation in November in Johannesburg, South Africa. Our friends at the Business Results Group...
[author] => SimpleXMLElement Object
(
[name] => Shelley Dolley
)
[category] => SimpleXMLElement Object
(
[@attributes] => Array
(
[term] => Announcements
[scheme] => http://www.sixapart.com/ns/types#category
)
)
[content] => SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => html
)
)
)
我的PHP代碼,這樣做是
$url = 'http://www.tompeters.com/atom.xml';
$xml = simplexml_load_file($url);
echo '<pre>';
foreach($xml->entry as $entry){
echo $entry->title;
echo "<br />";
foreach ($entry->link->@attributes as $attr){
echo $attr->href;
echo "<br />";
}
}
的問題是,@attributes
位打破代碼..
我如何獲得該HREF鏈接?
你*打破了代碼*說明是*的變化不工作plz幫助*。我相信你可以改進它。 –
@ÁlvaroG. Vicario對不起,我不明白你剛剛說了什麼? –
我的意思是說,你應該提供一個清晰的問題描述並提出一個問題,而不是放下一段代碼,讓我們猜測。比較«打破了代碼»與«觸發以下語法錯誤:‘意外‘@’,期待T_STRING或T_VARIABLE或‘{’或‘$’’»的 –