views:

121

answers:

1

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.

+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