2013-06-26 64 views
1

我想獲取RSS XML的原始字符串。我嘗試了下面,但我的字符串生成器結束了空白。什麼是正確的方法來做到這一點?從Rss20FeedFormatter獲取RSS/XML的原始字符串?

var rssFormatter = new Rss20FeedFormatter(feed, false); 
var output = new StringBuilder(); 
using (var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true })) 
{ 
    rssFormatter.WriteTo(writer); 
    return output; 
} 

回答

2

你可能要刷新你的作家......

var rssFormatter = new Rss20FeedFormatter(feed, false); 
var output = new StringBuilder(); 
using (var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true })) 
{ 
    rssFormatter.WriteTo(writer); 
    writer.Flush(); 
    return output; 
} 
相關問題