I need to serialize an object using datacontract serializer.
The problem is that i haven’t the object data in a stream or one string. I have an XmlElement with the xml contents.
I want to do:
DataContractSerializer ser = new DataContractSerializer(Xpto.GetType());
XmlReader = ... //i need the create an XmlReader (or XmlDictionaryReader) from a XmlElement (or XmlDocument)
Xpto x = (Xpto)ser.ReadObject(reader, true);
Any ideia?
You can use an
XmlNodeReaderto process anXmlElementobject: