quinta-feira, 31 de março de 2011

SVG XmlSerializer Classes

I've been struggling lately with getting a parser of the SVG file format working in .NET C#. Scavenging the web in search of one has turned out that the few that do exist are often coupled to vector graphics rendering libraries and/or are often incomplete. Some have turned to writing their own simple SVG parsers, usually just for the support of paths, which was not enough for my purposes.

Thinking that SVG should be a simple enough file format to handle, being XML-based, I tried to automatically generate classes for it using the XSD tool. It didn't work right out the bat because of some ill-defined attributes in the SVG.xsd file, but I finally managed to work around it and generate class files that XmlSerializer can read and write, and even tested them successfully with an Inkscape file.

Without further ado, you can find the source here. Feel free to use it for whatever you feel like and to comment if any questions pop out.