real world programming

coverting XML to a class

Posted by kevinup on November 20, 2007

I was working on writing some enhancements to my coverage.xml file that was generated from ncover (more on that on a future post). I wanted to avoid trying to use the .net XML classes like XmlDocument, mostly because the syntax is cumbersome . I’ve serialized and deserialized xml objects before, but I was thinking it would be awesome if I could generate a C# class just from my coverage.xml file.

I was trying to find out if someone had built something like that already. After looking around the web, and not finding anything promising, I finally I asked the .net oracle: James. Apparently what I needed was already in .net: xsd.exe. The syntax for what I needed to do was super easy:

This generated an coverage.xsd file:
xsd coverage.xml

And this generated my coverage class:
xsd coverage.xsd -c



Leave a Reply

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

You are commenting using your 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: