Reputation: 30656
What tools have you used to create class source code from xml files? Is this an edge case that I need to roll my own? I have need to create DTOs from some XML files, but the XML files are subject to change (add/remove attributes) so I need to be able to quickly update them.
I'm reallly not impressed with the .xml -> .xsd -> bloated .cs
approach, and was looking for something to hopefully generate simple POCOs for me. Are there any tools you've used or seen that do this?
Upvotes: 2
Views: 11507
Reputation: 3593
I realise that this is a rather old post and you have probably moved on. But I had the same problem as you so I decided to write my own program.
It is in no way elegant but it did the job for me.
You can get it here: Please make suggestions if you like it.
Upvotes: 0
Reputation: 4569
T4 sounds perfect for this.
It's essentially an ASP.NET like syntax to generate code based on your template.
You would write the template to output the code for the POCO as needed, and then embed code in the template to iterate over your XML collection.
T4 is part of Visual Studio 2008 (but undocumented), and 2010. The Microsoft DSL tools gives support for T4 for Visual Studio 2005 as a separate download.
http://msdn.microsoft.com/en-us/library/bb126445.aspx
Upvotes: 0
Reputation: 56550
There is a built-in way to do this in VS2008 and later, T4. Hanselman has a bunch of great links in one place.
Upvotes: 6