1
由於有多個列表的事實,我無法反序列化此表,我知道我需要一個列表,因爲他們重複我的trs,但也爲我的tds,因爲他們也重複,嘗試讀取tds的值時出現問題,因爲我以列表格式存在。如何反序列化具有多個列表的表
這裏是我的xml:
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
而且我的課:
Public Class table
Private newtr As List(Of tr)
<XmlElement()> _
Public Property tr() As List(Of tr)
Get
Return newtr
End Get
Set(ByVal value As List(Of tr))
newtr = value
End Set
End Property
End Class
Public Class tr
Private newtd As List(Of td)
<XmlElement()> _
Public Property td() As List(Of td)
Get
Return newtd
End Get
Set(ByVal value As List(Of td))
newtd = value
End Set
End Property
End Class
Public Class td
Private newvalue As String
<XmlElement()> _
Public Property td() As String
Get
Return newvalue
End Get
Set(ByVal value As String)
newvalue = value
End Set
End Property
End Class
而且我的代碼:
Public Sub test2()
Dim rr As New table()
Dim xx As New XmlSerializer(rr.GetType)
Dim objStreamReader2 As New StreamReader("table.xml")
Dim rr2 As New table()
rr2 = xx.Deserialize(objStreamReader2)
For Each ii As tr In rr2.tr
MsgBox(ii.td)
Next
End Sub
因此,任何關於我如何能得到的值中的每一個想法在tds裏面?謝謝!
如果它不是史蒂文了。 :) – user1676874
啊!這是你:)我沒有認出你的數值。我需要更新我的照片。恐怕這有點太令人不安。 –
我應該解決這個問題,你看起來像一個程序員,沒有錯。 :) – user1676874