1.) Find xsd.exe utility to convert .xsd into .cs class
- xsd.exe should be found here: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\
2.) Run xsd.exe against the file to be converted.
- xsd /c yourfile.xsd
- This will turn the .xsd file into a C# class
3.) Now, with the C# class, you are able to deserializing the XML into an instance of your new object.
XmlSerializer serializer = new XmlSerializer(typeof(yourClass));
string filename = Path.Combine(FilePath, "theXml.xml");
yourClass myClass = serializer.Deserialize(new FileStream(filename, FileMode.Open)) as yourClass;
if (myClass != null)
{
//...
}
No comments:
Post a Comment