Introduction
Series Part 1) This sample generates C# classes from XML. It uses hard coded relations between XML format and class format such that, elements are classes and attributes are properties. Therefore, it won't work with XML formats where elements contain values. I will release another step in the series for that task. Also how to handle embedded classes and serializers. This is just the first step but actually even this can be quite useful if you do a lot of work in XML because generally that is how you want your XML formatted. I will also release some formatters that are compatible to come.
Refrences:
Utililzes tips/articles:
http://www.codeproject.com/KB/silverlight/Silverlight_Splitter.aspx
http://www.codeproject.com/Tips/300799/Iterate-XML-with-XMLReader
Using the code
XmlEntityToClassGenerator.ToClass("<Car name=\"Cayenne\"></Car>")
will generate:
public class Car
{
public string Name {get;set;}
}
Refer to file XmlEntityToClassGenerator.cs. If you have a question I WILL append the article with the comments. Consider this a tip and trick with a downloadable sample please. Otherwise, if you want a book go buy one, I am not here to entertain you with a funny story and a segway into XML stuff followed by a dreary explaination parroting the code which is right there. I am however, very interested in helping anyone or talking about it. So, let the 1's / flames / comments fly !.
Thanks,
R.J.