From raw xml (no schema) to C # class?
All code generation tools I know will require schemas, but you can easily generate them from an XML data file.
You can use xsd.exe
to output XML schema from XML data file:
xsd.exe yourdata.xml
This will create yourdata.xsd
. Of course, xsd.exe can only guess - pretty good sometimes, not so good at other times. You can check (and possibly change) the schema before proceeding.
(You can do the same in Visual Studio: load an XML file and choose Create Schema from the XML menu).
From this schema, you can create serializable classes:
xsd.exe yourdata.xsd /classes
This will create a file yourdata.cs
that contains a C # class that can be serialized and deserialized from your XML data files.
Mark
source to share