cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
I'm trying to generate some xml like this:
Of concern is the address.. It is to be such that the first block of address is the current address. the previous address comes second
My code looks something like:
The xml formed, annoyingly, is:
Anyone know how to get the array to serialise out as a sequence of elements <address> without the enclosing type?
I cant just ignore the array and label each Property with
[System.Xml.Serialization.XmlElement("address")]
Because it errors on reflecting - "address" appears twice
Also, of further nuisance, the serializer will only serialize public fields, which means my array has to be public, which means it can be seen by other coders. The idea was to develop a library that was more foolproof in this regard. Any ideas?
VB.NET:
<root>
<address>
<child1/>
<child2/>
</address>
<address>
<child1/>
<child2/>
</address>
<zzz>
<child1/>
</zzz>
</root>
Of concern is the address.. It is to be such that the first block of address is the current address. the previous address comes second
My code looks something like:
VB.NET:
[System.Xml.Serialization.XmlArray("address")]
Public addresses(0 to 1) as New AddressXMLBlockRepresentation
[System.Xml.Serialization.XmlIgnore()]
Public Property CurrentAddress
Get
Return addresses(0)
End Get
Set
addresses(0) = value
End Set
End Property
[System.Xml.Serialization.XmlIgnore()]
Public Property PreviousAddress
Get
Return addresses(1)
End Get
Set
addresses(1) = value
End Set
End Property
The xml formed, annoyingly, is:
VB.NET:
<root>
[B]<AddressXMLBlockRepresentation>[/B]
<address>
<child1/>
<child2/>
</address>
<address>
<child1/>
<child2/>
</address>
[B] </AddressXMLBlockRepresentation>[/B]
<zzz>
<child1/>
</zzz>
</root>
Anyone know how to get the array to serialise out as a sequence of elements <address> without the enclosing type?
I cant just ignore the array and label each Property with
[System.Xml.Serialization.XmlElement("address")]
Because it errors on reflecting - "address" appears twice
Also, of further nuisance, the serializer will only serialize public fields, which means my array has to be public, which means it can be seen by other coders. The idea was to develop a library that was more foolproof in this regard. Any ideas?