You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
var sw = new StringWriterWithEncoding(Encoding.UTF8);
using (XmlWriter xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { Async = true, Indent = true }))
{
var writer = new RssFeedWriter(xmlWriter);
// Create item
var item = new SyndicationItem()
{
Title = "Rss Writer Avaliable",
Description = "The new Rss Writer is now available as a NuGet Package!",
Id = "https://www.nuget.org/packages/Microsoft.SyndicationFeed.ReaderWriter",
Published = DateTimeOffset.UtcNow
};
item.AddCategory(new SyndicationCategory("Technology"));
item.AddContributor(new SyndicationPerson("test", "[email protected]"));
await writer.Write(item);
xmlWriter.Flush();
}
class StringWriterWithEncoding : StringWriter
{
private readonly Encoding _encoding;
public StringWriterWithEncoding(Encoding encoding)
{
this._encoding = encoding;
}
public override Encoding Encoding {
get { return _encoding; }
}
}
Actual output:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel><item>
<title>Rss Writer Avaliable</title>
<description>The new Rss Writer is now available as a NuGet Package!</description>
<author>[email protected]</author>
<category>Technology</category>
<guid isPermaLink="false">https://www.nuget.org/packages/Microsoft.SyndicationFeed.ReaderWriter</guid>
<pubDate>Mon, 24 Aug 2020 02:59:48 GMT</pubDate>
</item>
Notice how this is INVALID XML
The text was updated successfully, but these errors were encountered:
Replacing the call to the synchronous xmlWriter.Flush() with it's async counterpart and awaiting it like so; await xmlWriter.FlushAsync() fixes this issue.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Example code on your readme:
Actual output:
Notice how this is INVALID XML
The text was updated successfully, but these errors were encountered: