我寫了一個網頁,它從RSS接收XML文件並通過某些標記解析它。我已經在我計劃使用的數據的本地副本上進行了測試,並且工作正常。問題在於我無法弄清楚如何在不同的網頁上調用RSS文件並解析其數據。使用Javascript從RSS提取數據Atom提要
這裏是我的設置解析器代碼:
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", ".../NewsFeed.aspx?output=Atom", false);
下面是XML文件的頭,我得到當我檢查RSS頁面:
<?xml version="1.0" encoding="UTF-8" ?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
<title type="text"> News</title>
<subtitle type="text">A syndication of the most recently published news.</subtitle>
<id>uuid:64d61c8e-c5d7-4529-b5a3-2dcd4097238b;id=50</id>
<rights type="text">© 2013 <owner goes here>. All Rights Reserved.</rights>
<updated>2013-07-09T13:34:27Z</updated>
<link rel="alternate" href=".../Default.aspx" />
<link rel="self" href=".../NewsFeed.aspx" />
我編輯的鏈接,發佈目的。我曾嘗試使用RSS文檔中列出的兩個鏈接以及open xml方法中的外部提要的URL,但我沒有運氣。
xmlhttp.open("GET", "link goes here", false);
有誰知道我會怎麼讀RSS?順便提一下,Feed是以Atom格式返回的標準RSS提要(2.0)。
YQL或雅虎管道 – dandavis
我不太清楚你的意思。我不是很熟悉HTML/JS和XML – user2517628
的互動,當有人給我一個我沒有聽說過的建議時,我做的第一件事就是谷歌它... – dandavis