I have defined schema for xml in file "packetTemplate.xsd".Using ms tool "xsd.exe" i have generated class "PacketTemplate" corresponding to schema.Does dot net provides api that can load xml document by refering to file and returns object of class PacketTemplate.
views:
121answers:
1
+3
A:
You can find some examples here.
A snippet:
PacketTemplate myTemplate;
XmlSerializer mySerializer = new XmlSerializer(typeof(PacketTemplate));
FileStream myFileStream = new FileStream("c:/mtTestClass.xml",FileMode.Open);
myTemplate= (PacketTemplate)mySerializer.Deserialize(myFileStream);
Deserialize
has various overloads, you can also use an XmlReader
.
Alex Bagnolini
2009-11-26 12:17:12