我有自己的RSS提要,这是:
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'>
<channel>
<atom:id>tag:blogger.com,1999:blog-2079382764445278058</atom:id>
<lastBuildDate>Wed, 23 Oct 2013 18:38:23 +0000</lastBuildDate>
<title>Whaaa</title>
<description>Blog tests....</description>
<link>http://whateverblog.blogspot.com/</link>
<managingEditor>noreply@blogger.com (The author)</managingEditor>
<generator>Blogger</generator>
<openSearch:totalResults>1</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
<item>
<guid isPermaLink='false'>tag:blogger.com,1999:blog-2079382764445278058.post-6231173351434517354</guid>
<pubDate>Wed, 23 Oct 2013 13:15:00 +0000</pubDate>
<atom:updated>2013-10-23T11:38:23.407-07:00</atom:updated>
<title>Lorem ipsum</title>
<description>span style="background-color: white; color: #444444; font-family: helvetica, arial, sans-serif; font-size: 16px; line-height: 20px;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</span></description>
<link>http://myblog.blogspot.com/2013/10/lorem-ipsum.html</link>
<author>noreply@blogger.com (The Author)</author>
<thr:total>0</thr:total>
</item>
</channel>
</rss>
我有帖子的html模板,但我的问题是我不知道什么是获取此信息的最佳方式,复制它&amp;将其粘贴到template.html ....
你们有什么解决办法吗?
最简单的方法是什么?
////为了简洁起见,我们只想说:
Published
Title
Description
Author
如何使用该信息创建html文档。 例如:
firstpost.html(firstpost是帖子标题的名称..)
<div id="title">Here Goes Post Title </div>
<divid="date">Here Goes Post Submission Date </div>
<div id="content"> Here Goes Post Description </div>
<div id="author"> Here goes Post Author </div>
答案 0 :(得分:0)
例如使用如下函数:
function getRssFeed($feedString) {
$content = file_get_contents($feedString);
$x = new SimpleXmlElement($content);
echo "<ul>";
foreach($x->channel->item as $entry) {
echo "<li><a href='{$entry->link}' title='{$entry->title}'>" . $entry->title . "</a></li>";
}
echo "</ul>";
}
您使用 SimpleXmlElement
解析非常简单的Feed