使用SimpleXmlElement从wordpress RSS订阅获取作者问题
问题描述:
干草,我试图从wordpress博客解析RSS订阅源。到目前为止,一切工作如预期,这里是我的代码使用SimpleXmlElement从wordpress RSS订阅获取作者问题
<?php
$feedUrl = "FEED URL";
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);
$channel = $xml->channel;
$items = $channel->item;
foreach($items as $item){
echo "<a href='".$item->link."'>".$item->title."</a>";
echo $item->description;
echo $item->pubDate;
}
?>
但是,我似乎有问题得到该职位的作者。数据已经在某个地方,因为当Safari呈现作者出现的Feed时。
这里是我的RSS提要
SimpleXMLElement Object
(
[@attributes] => Array
(
[version] => 2.0
)
[channel] => SimpleXMLElement Object
(
[title] => My Blog title
[link] => http://blog.com/new/blog
[description] => Just another WordPress site
[lastBuildDate] => Thu, 22 Jul 2010 08:02:19 +0000
[language] => en
[generator] => http://wordpress.org/?v=3.0
[item] => Array
(
[0] => SimpleXMLElement Object
(
[title] => Second post
[link] => http://blog.com/new/blog/?p=5
[comments] => http://blog.com/new/blog/?p=5#comments
[pubDate] => Thu, 22 Jul 2010 08:02:19 +0000
[category] => SimpleXMLElement Object
(
)
[guid] => http://blog.com/new/blog/?p=5
[description] => SimpleXMLElement Object
(
)
)
[1] => SimpleXMLElement Object
(
[title] => Hello world!
[link] => http://blogl.com/new/blog/?p=1
[comments] => http://blog.com/new/blog/?p=1#comments
[pubDate] => Thu, 22 Jul 2010 07:22:40 +0000
[category] => SimpleXMLElement Object
(
)
[guid] => http://blog.com/new/blog/?p=1
[description] => SimpleXMLElement Object
(
)
)
)
)
)
任何帮助将是真棒!
感谢
答
在WordPress的RSS源,作者信息是在<dc:creator>
标签。看看它是否也适用于您的Feed。
由于标记名称中含有冒号,XML解析器会吞下该标记。
请参阅this question了解如何让这些标签显示。
+0
谢谢,此答案中的链接解释了如何获取作者(创作者)。 – dotty 2010-07-22 10:13:53
请显示Feed的源代码。 – 2010-07-22 09:51:21
添加提要源代码 – dotty 2010-07-22 10:00:29