0
我有这个链接http://lazhalazha.livejournal.com/data/rss
其中有RSS,我需要的是值的数组,即链接到帖子。这是我迄今为止...PHP对象 - 我怎样才能访问这个值
$xml = simplexml_load_file('http://lazhalazha.livejournal.com/data/rss');
foreach ($xml->channel->item as $item){
print_r($item->guid);
}
输出是一系列的这些对象
SimpleXMLElement Object
(
[@attributes] => Array
(
[isPermaLink] => true
)
[0] => http://lazhalazha.livejournal.com/713.html
)
此对象转换为字符串解决这一点,那么它传递正确的网址,而不是对象。
$xml = simplexml_load_file('http://lazhalazha.livejournal.com/data/rss');
$linkArray = array();
foreach ($xml->channel->item as $item){
$guid = (string)$item->guid;
array_push($linkArray, $guid);
}
什么'不work'关于你的第一个选项? – Neal 2012-03-06 14:44:12
@Neal输出与末尾没有[0]相同。 – sed 2012-03-06 14:46:00
请通过php手册中的simplexml基本用法示例。 – Gordon 2012-03-06 14:50:02