I am trying to generate an .xml file using C#. I am using a class generated from an XSD for this purpose.
To be precise I am doing some experiment with Nunit results.xsd.
I need to generate some elements multiple times. I have below code at end of each function
var serializer = new XmlSerializer(typeof(resultType));
using (var stream = new StreamWriter(@"C:\test.xml",true))
serializer.Serialize(stream, data);
When I execute this multiple times, I am seeing the xml tag with XML version and encoding getting appended every time.
How can I put them as a individual functions so that I can call the objects multiple times for creating multiple XML elements of same type and in the end save the XML with data? I need the generated file to have structure similar to Nunit's results XML file.
List<resultType>, if that's what you're looking to do.