我有这个链接http://lazhalazha.livejournal.com/data/rss
里面有RSS,我需要得到的是guid
值数组,这是指向帖子的链接。这就是我到目前为止......
$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
)
通过将此对象转换为字符串来解决此问题,然后传递正确的URL而不是对象。
$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);
}
答案 0 :(得分:0)
<?php
$_temp = array();
$xml = simplexml_load_file('http://lazhalazha.livejournal.com/data/rss');
foreach ($xml->channel->item as $item){
$_temp[] = (string)$item->guid[0];
}
print_r($_temp);
?>