CTX (Class to Xml) tool is a very simple tool which provides you a code editing environment in C# and VB.NET, compiles the source codes and lets you see the Xml output of all serializable types once successfully compiled.
Do you use Xml Serialization in .NET – if yes, you might be interested in this tool!
Have you ever thought “Hmm…now that I have written a serializable class, I wonder how will it look when it is Xml Serialized”?
If yes, you are in good company :). Sometime back I was involved in a project in which I had to develop a lot of business entity classes which would be Xml Serialized. Since these classes had to adhere to a specific schema, I had a tough time synchronizing the Xml Attributes and the final xml schema it generated when xml serialized.
The sequence of how I would go about doing this was like this:
- I would develop a draft version of xml schema.
- I would create a simple console project in which I would start writing the class to be serialized.
- This project will have a small code snippet which will create an instance of the serializable class and xml serialize it and then finally print out the xml output.
- I will keep comparing this output with my xml schema until they are in sync.
As I got involved in more and more projects (many of them my own 🙂 ) which came to have similar requirements, I decided to create a little tool which would automate the above tasks.
Introducing the Class to Xml (CTX) tool – a very simple tool which provides you a code editing environment in C# and VB.NET, compiles the source codes and lets you see the Xml output of all serializable types once successfully compiled.
How to use the tool
- Open up the source code files of the serializable classes you want to get the xml for (including all the files that are referenced) and select the language.
- Press F5. The whole list of files will be compiled.
- If compilation is successful, the Output pane would list all serializable types available in the assembly. If compilation failed, the Errors pane would list the errors.
- After successful compilation, select the required serializable type in the combo box; the Xml representation is displayed in the Serialized Xml text box.
The current test version source code (probably terrible) in Visual Studio 2005 is available here (The site is down due to site maintenance, please wait while I resolve this ASAP).
Do check it out and let me know your comments.
I plan to finalize the code soon…er, I have no idea how “soon” though 🙂