Answer the question
In order to leave comments, you need to log in
How to write data to one xml file without overwriting?
There is an array with links to rss sites, I load the xml structure from the links, but I can’t load all the xml structures from all the links of the array, because it overwrites them, as a result I load only one structure from one link, and other links remain in the array.
string[] rsslinks = { "https://www.e-ir.info/category/blogs/feed/", "https://www.reddit.com/r/worldnews/.rss"};
OnGetFeed(rsslinks);
void OnGetFeed(string[] uri)
{
foreach (string url in uri)
{
string writePath = @"D:\RssFeed\RSS_feed.xml";
XmlDocument doc = new XmlDocument();
doc.Load(url);
doc.Save(writePath);
}
Answer the question
In order to leave comments, you need to log in
so you create a NEW XmlDocument object in each iteration of the foreach loop
doc = new XmlDocument();
Take the creation out of the loop. and do not overwrite, but supplement)) although I feel you want not just a text in a row, but to preserve the xml structure, then parse each file / link for you and collect what you need into one of your own.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question