So the VSMDI config file is xml… That’s a good thing, because VisualStudio gives you a few tools for code generation when it comes to XML. Are you sick and tired of writing code to traverese an XML document, or sick of writing lines to create nodes and elements and insert them in the right order? Well, if you’ve already got a sample of the format you want, you can perform this useful shortcut:
-
Fire up Visual Studio, and add the xml file to your project
-
Xml > Create Schema
-
Add the new XSD file to your project
-
Open a command prompt and navigate to the XSD file
-
xsd.exe -c -l:c# -n:NAMESPACE nameofxsd.xsd
And voila, a class to interface with
Instantiate, manipulate, and then write it out with:
XmlSerializer ser =
new XmlSerializer(typeof(TestLists));
ser.Serialize(newStreamWriter("out.xml"), testList);