Overwriting feed in feed file

52 Views Asked by At

I have a news website that has rss.

when I write first News in rss file. It work fine.

XmlWriter atomWriter = XmlWriter.Create(HttpContext.Current.Server.MapPath(@"~\NewsFeed\NewsFeed.xml"));
Atom10FeedFormatter atomformatter = new Atom10FeedFormatter(Newsfeed);
atomformatter.WriteTo(atomWriter);

XmlWriter NewsRssWriter = XmlWriter.Create(HttpContext.Current.Server.MapPath(@"~\NewsFeed\NewsFeed.xml"));

Rss20FeedFormatter rssformatter = new Rss20FeedFormatter(Newsfeed);
rssformatter.WriteTo(NewsRssWriter);
NewsRssWriter.Close();

but when I enter second news, this was overwrite on first news data.

I know reason. this is becuase belove code:

XmlWriter atomWriter = XmlWriter.Create(HttpContext.Current.Server.MapPath(@"~\NewsFeed\NewsFeed.xml"));

but don't know how to solve this case. Rss20FeedFormatter Class and Atom10FeedFormatter Class both get parameter of XmlWriter Class type.

I Thanks anyOne that guide me ;)

0

There are 0 best solutions below