1
我試圖從the feed獲得未解答的問題列表,但我在閱讀時遇到問題。閱讀堆棧溢出RSS源
const string RECENT_QUESTIONS = "https://stackoverflow.com/feeds";
XmlTextReader reader;
XmlDocument doc;
// Load the feed in
reader = new XmlTextReader(RECENT_QUESTIONS);
//reader.MoveToContent();
// Add the feed to the document
doc = new XmlDocument();
doc.Load(reader);
// Get the <feed> element
XmlNodeList feed = doc.GetElementsByTagName("feed");
// Loop through each item under feed and add to entries
IEnumerator ienum = feed.GetEnumerator();
List<XmlNode> entries = new List<XmlNode>();
while (ienum.MoveNext())
{
XmlNode node = (XmlNode)ienum.Current;
if (node.Name == "entry")
{
entries.Add(node);
}
}
// Send entries to the data grid control
question_list.DataSource = entries.ToArray();
我討厭發佈這樣的「請修復代碼」問題,但我真的被卡住了。我試了幾個教程(一些給編譯錯誤),但沒有幫助。我假設我使用XmlReader
和XmlDocument
正確的方式,因爲這是每個指南中的常見事情。
你能說出你得到的錯誤和錯誤的做法嗎? – mmcdole 2009-02-01 21:51:01
您可以考慮使用 而不是http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx 。 – Brian 2009-02-01 21:51:43