我无法将 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
所以我在表单上进行了实际的反序列化调用,但这似乎不是我的问题,因为当我运行它时,除了事务 ID 之外,实际上每个属性都被正确填充。我究竟做错了什么??