Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Example writer code does not work - doesn't write closing tags #49

@Cloudmersive

Description

@Cloudmersive

Example code on your readme:

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", "test@mail.com"));

    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>test@mail.com</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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions