我無法將xml屬性反序列化到類屬性中。Vb.Net XmlDeseralize xml屬性到類對象中
<?xml version="1.0" encoding="UTF-8" ?>
<Ball clientid="xyz">
<Name>Tommy</Name>
<ballColor transactionid="1234">White</ballColor>
<radius>9</radius>
<PowerLevel>9001</PowerLevel>
<RandomProp>This is another property</RandomProp>
</Ball>
是我正在使用的XML ...現在我會發布我的代碼。事情是我能夠得到的clientid進入房地產,而不是「TRANSACTIONID」所以我無法拔出形式
Imports System.Xml.Serialization
Public Class Ball
Inherits ballColor
Public Property Name As String
Public Property radius As Double
Public Property PowerLevel As String
Public Property RandomProp As String
<XmlAttribute("clientid")> Public Property clientid() As String
Public Sub New()
End Sub
End Class
<XmlRoot("Ball")>
Public Class ballColor
<XmlElement("ballColor")> Public Property ballColor As String
<XmlAttribute("transactionid")> Public Property transactionid As String
Public Sub New()
End Sub
End Class
所以我有實際的反序列化調用一個子元素的屬性但這似乎不是我的問題,因爲當我運行這個時,字面上每個屬性都被正確填充,除了transactionid。我究竟做錯了什麼??
耶!!!這工作,你搖滾!非常感謝 – Brandon 2013-03-26 15:17:27