I want to make an xml file but add certain elements selectively. I would like to build those elements in memory and be able to choose whether to be written to the xml file or not. Is this possible? I’m using C# WinForms. I already looked at XmlDocument which will allow me to build an entire xml in memory but I don’t want this since it’s not good for large data and also takes too much memory.
Share
If you have a stream, named say
stream, then you can create an XmlWriter byThen, you can create your elements, (which are type
XmlElement), and call theWriteTomethod on each element you want to add, passing as an argument the XmlWriter created byXmlWriter.Create.