[英]XML Deserialization of child nodes to C# objects
Given the following XML structure: 给定以下XML结构:
<RootNode>
<NodeA>
<Value>1</Value>
<Value>2</Value>
<NodeA>
<NodeB>
<Value>100</Value>
<Value>200</Value>
<NodeB>
</RootNode>
How do I deserialize this to the following c# objects 我如何反序列化为以下c#对象
List<NodeA> and List<NodeB>
Use XMLDocument.SelectNodes to create a new object for each child node you want to process, then use a generic method to create and cast a new C# object for each node. 使用XMLDocument.SelectNodes为要处理的每个子节点创建一个新对象,然后使用通用方法为每个节点创建和强制转换一个新的C#对象。
See also: split xml document into chunks and How to Deserialize XML document . 另请参阅: 将xml文档拆分为多个块,以及如何对XML文档进行反序列化 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.