利用System.Xml.Serialization进行序列化与反序列化操作
System.Xml.Serialization能够很方便地将XML文件转换为对象,或者将对象转换为XML文件。
假设:我们有下列这样的一段XML
<XML>
<S1 A1="" A2="" A3="" />
<S2 B1="" B2="">
<O C1="" C2=""/>
<O C1="" C2=""/>
<O C1="" C2=""/>
...
</S2>
</XML>
1.根据XML的结构创建对象
Public Class XmlDoc
Public Property Node1 As S1
Public Property Node2 As S2
End Class
Public Class S1
Public Property A1 As String
Public Property A2 As String
Public Property A3 As String
End Class
Public Class S2
Public Property B1 As Double
Public Property B2 As Integer
Public Property olist As List(Of O)
End Class
Public Class O
Pub