How can I keep a .XML file in memory, then save the document to disc as a regular XML file?
I'm going to be doing some webscraping and my plan is to have something like this:
public class Searcher
{
public void Search(string searchTerm)
{
}
private void Search(string term)
{
//Some HTMLAgilityPack Voodoo here
}
private void SaveResults()
{
//Actually save the results as .XML file.
}
}
Is there a way I can keep an .XML file with its contents and everything in memory, and then save the document to disc as a regular XML file开发者_C百科?
Look into XDocument.Load and XDocument.Save with LINQ to XML if you're using .NET 3.5+
Either the XDocument or XmlDocument classes will allow you to keep XML in memory as XML.
精彩评论