Serialize class into Atom format

1.8k views Asked by At

I have to export one c# class into a xml file which should be in the atompub format. I've read a lot of articles, but i still don't understand the main thing - how am i going to represent my class data ( properties information) in the xml file

1

There are 1 answers

1
flq On

The System.ServiceModel.Syndication namespace contains a "serializer" to both atompub and rss. I use those classes in a project of mine, which is Open Source, so here's the link:

https://github.com/flq/Rf.Sites/blob/master/Rf.Sites/Features/Models/FeedModel.cs

Basically you create SyndicationItems which you put into a SyndicationFeed. From a feed you can obtain an Atom10 or Rss20 Formatter which you combine with an XmlTextWriter to get your output.