I have a class that processes XML files. It works, but the problem is that, everything is being processed in RAM. I need to do something (like using XmlWriter class) to make it save on HDD while creating a new XML file (the data is very large that’s why).
How to do that in the best way? I hope there’s no need to change XDocument into XmlDocument :/
e.g. – I have something like XML structure below and I want to add one node, save it into the file, dispose the element, then create a new node, save it… etc.
<root>
<element no='1' />
<element no='2' />
<element no='3' />
<element no='4' />
</root>
I’ve haven’t done this myself but this article should help, and yes, you can carry on using XDocument.
From the article:
In the article the author is talking about reading from the document, whereas you’re talking about writing. However, I think the key here is the XNode class, which also has a WriteTo method (huzzah!).