我正在尝试创建一些这样的XML:
<parameter name="srid" type="java.lang.Integer">24729</parameter>
注意标签被称为参数,它除了实际值外还有两个属性,一个名称和一个类型。
这是我到目前为止所做的:
type parameter(paramName, javaType, paramValue) =
let mutable pName = paramName
let mutable pType = javaType
let mutable pValue = paramValue
public new() =
new parameter("","","")
[<XmlAttributeAttribute("name")>]
member this.PName with get() = pName and set v = pName <- v
[<XmlAttributeAttribute("type")>]
member this.PType with get() = pType and set v = pType <- v
也许我完全走错方向,但我不确定如何表示标签的实际价值?
更新:也许我应该提一下,这个参数将是一个更大的“参数”标签中的四个之一。像这样:
<parameters>
<parameter name="srid" type="java.lang.Integer">24729</parameter>
...other parameter tags...
</parameters>
答案 0 :(得分:2)
好的,所以你需要
[<XmlText>]
要序列化节点值的属性的
属性
所以,在你的情况下,你会有像
这样的东西type parameter(paramName, javaType, paramValue) =
let mutable pName = paramName
let mutable pType = javaType
let mutable pValue = paramValue
public new() = new parameter("","","")
[<XmlAttributeAttribute("name")>]
member this.PName with get() = pName and set v = pName <- v
[<XmlAttributeAttribute("type")>]
member this.PType with get() = pType and set v = pType <- v
[<XmlText>]
member this.PValue with get() = pValue and set v = pValue <- v