Domanda

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;
}
È stato utile?

Soluzione

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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top