我有一个像这样的xml字符串:
<root>
<header>
<reqType>REQUEST</reqType>
<priority>1</priority>
<channel>TTP</channel>
<synasyn>true</synasyn>
<zip>false</zip>
</header>
<body>
<command>getcustInfo</command>
<customerID>14231131</customerID>
</body>
</root>
下面是我的代码
[XmlRoot ("root")]
public class root
{
public header header;
[XmlElement("body")]
public string body;
}
[XmlRoot("header")]
public class header
{
[DataMember(Order = 1,isrequired = true)]
public string reqType;
.....
}
当我在上面反序列化xml字符串时:
root data = CompressHelper.fromXML<root>(xml);
我得到的结果“ body”元素是“ getcustInfo”
所以问题是我如何反序列化以字符串形式获取结果“ body”:
<command>getcustInfo</command>
<customerID>14231131</customerID>