Ahhh, Code Generation…

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);

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: