我正在使用 GoogleFeed API 将 RSS 提要显示为 HTML:
var feedcontainer=document.getElementById("feeddiv")
var feedurl="MY FEED URL"
var feedlimit=20
var rssoutput=""
function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl) //Google Feed API method
feedpointer.setResultFormat(google.feeds.Feed.MIXED_FORMAT)
feedpointer.setNumEntries(feedlimit) //Google Feed API method
feedpointer.load(displayfeed) //Google Feed API method
}
function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries
for (var i=0; i<thefeeds.length; i++)
rssoutput+="<a href='" + thefeeds[i].link + "' style='text-decoration:none'>" + "<h1 class='pub'>" + thefeeds[i].title + "</h1>" + "</a>" + new Date(thefeeds[i].publishedDate) + thefeeds[i].content + "<p class='text-small-hilite'><a href='" +thefeeds[i].link + "'>" + "Read full post" + "</a></p>"
rssoutput+=""
feedcontainer.innerHTML=rssoutput
}
else
alert("Error fetching feeds!")
}
window.onload=function(){
rssfeedsetup()
}
我还想在我的 tag 中将 CDATA 元素显示为 HTML。我试过 .xmlNode.getElementsByTagName 但没有奏效。
<item>
<title>
MY TITLE
</title>
<link>MY URL</link>
<comments>MY URL</comments>
<pubDate>Fri, 17 Oct 2014 19:06:53 +0000</pubDate>
<dc:creator>
<![CDATA[ MY AUTHOR ]]>
</dc:creator>
是否可以将 CDATA“我的作者”中的文本显示为 HTML?