开发者

Take string received from Web Service and populate class

I have a file of classes 开发者_StackOverflow社区that I generated from an xsd file using the XSD Tool. I receive an XML string response from a web service. How do I populate the generated classes with the string xml received?


You can use System.Runtime.Serialization.DataContractSerializer to generate the class.

TheClass result = null;
DataContractSerializer dcs = new DataContractSerializer(typeof(TheClass));
using(StringReader reader = new StringReader(xml))
{
    using(XmlReader XmlReader = new XmlReader(reader))
    {
        result = dcs.ReadObject() as TheClass;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜