Reputation: 21271
I'm trying to create some XML like this:
<parameter name="srid" type="java.lang.Integer">24729</parameter>
notice that the tag is called parameter and it has two attributes, a name, and a type in addition to the actual value.
Here is what I have so far:
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
Maybe I'm going in the wrong direction altogether, but I'm unsure how to represent the actual value of the tag?
update: perhaps I should mention that this parameter will be one of four inside a larger "parameters" tag. Like so:
<parameters>
<parameter name="srid" type="java.lang.Integer">24729</parameter>
...other parameter tags...
</parameters>
Upvotes: 1
Views: 370
Reputation: 2382
ok, so you need
[<XmlText>]
attribute for the property that you want to serialize the value of the node
so, in your case, you would have something like
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
Upvotes: 2