How to Deserialize XMLDocument to object in C#?

Posted by Deepfreezed on Stack Overflow See other posts from Stack Overflow or by Deepfreezed
Published on 2010-04-22T22:05:36Z Indexed on 2010/04/22 22:13 UTC
Read the original article Hit count: 678

I have a .Net webserivce that accepts XML in string format. XML String sent into the webserivce can represent any Object in the system. I need to check the first node to figure out what object to deserialize the XML string. For this I will have to load the XML into an XMLDocument (Don't want to use RegEx or string compare). I am wondering if there is a way to Deserialize the XMLDocument/XMLNode rather that deserializing the string to save some performance? Is there going to be any performance benefit serializing the XMLNode rather that the string?

Method to Load XMLDocument

public void LoadFromString(String s)
{
    m_XmlDoc = new XmlDocument();
    m_XmlDoc.LoadXml(s);        
}

Thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#