문제

I am trying to get the raw string of the RSS xml. I tried the below but my string builder ends up blank. What is the correct way to do this?

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;
}
도움이 되었습니까?

해결책

You probably want to flush your writer...

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top