1
我正在使用RSS源作爲數據源。我已經調整了如何檢索數據以使用WebClient.DownloadStringAsync方法。在我使用XmlReader.Create方法之前。然後,我使用結果作爲數據源來綁定到WPF中的TextBlock。爲什麼當XmlReader結果不會導致DownloadStringAsync結果具有奇怪的字符?
由於我在顯示結果時進行了更改,所有特殊編碼字符都顯示爲奇數字符。會喜歡一些幫助確保我保持正確的編碼,以便我的顯示值不會有奇怪的字符。
// WebClient code...
private void GetFeed(int i)
{
Uri _feedUri = new Uri(_feedList[i]);
webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(stringStringCompletedEvent);
webClient.DownloadStringAsync(_feedUri, _feedTokenList[i]);
}
private void stringStringCompletedEvent(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
string xmlString = e.Result;
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
doc.Save(@"C:\CashierData\msnbc-top.xml");
}
}
這是我以前使用XmlReader下載和解析提要的代碼。
XmlReader reader = XmlReader.Create(feed, settings);
謝謝,我會試試 – discorax 2010-07-01 21:00:47
這工作。謝謝。 – discorax 2010-07-01 22:12:09