I am using the XmlSerializer
to do some serialization work. I was wondering if it is possible to "generically" deserialize from the XmlDocuement.
Concrete: If I have an XML File I would watch the tag and compare it with my DTO Model. Is this possible (better: Does .NET support this?) ? Maybe using an XSD file or something?
Example (without generic deserialization):
XmlDocument myDocument = new XmlDocument();
myDocument.Load(xml);
MemoryStream stream = new MemoryStream();
myDocument.Save(stream);
// Here I would like to use an interface instead and load the correct type of object.
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
MyClass myObject;
serializer.Serialize(stream, myObject);
No comments:
Post a Comment