我使用simplexml_load_file,期望它可以在url上使用,奇怪的是一些數據丟失。simplexml_load_file只返回xml的部分數據
我的PHP
$url = "http://www.thestar.com.my/RSS/Lifestyle/Women/";
$xml = simplexml_load_file($url);
echo "<pre>";
print_r($xml);
部分結果
[item] => Array
(
[0] => SimpleXMLElement Object
(
[guid] => {936842CF-550D-4CAB-A840-23BB4E766B8E}
[link] => http://www.thestar.com.my/Lifestyle/Women/Fashion/2014/07/02/Jamy-Yang-Mingjie-Shared-travelling-values
[title] => SimpleXMLElement Object
(
)
[description] => SimpleXMLElement Object
(
)
[pubDate] => Wed, 02 Jul 2014 00:00:00 +08:00
[enclosure] => SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://www.thestar.com.my/~/media/Images/TSOL/Photos-Gallery/features/2014/07/02/JamyYangMingjie020714.ashx?crop=1&w=460&h=345&
[length] =>
[type] => image/jpeg
)
)
)
item->title
成爲SimpleXMLElement對象?
是的,這**完全沒有問題**。它總是一個SimpleXMLElement,它只是在這裏以一種有用的方式不能對SimpleXMLElement使用'print_r'。查看鏈接副本中的所有答案。 – hakre