SteMMo
SteMMo

Reputation: 418

Deserializing array of items with attribute

I need to deserialize this block of data

<colors>
    <color id='mnemonic1'>RRGGBB1</color>
    <color id='mnemonic2'>RRGGBB2</color>
    <color id='mnemonic3'>RRGGBB3</color>
    <color id='mnemonic4'>RRGGBB4</color>
</colors>

if I define this

<XmlArray("colors")> <XmlArrayItem("color")> Public colors() As DefColor
..
Public Class DefColor
    <XmlAttribute("id")> Public id As String
    <XmlElement("color")> Public defColor As String
End Class

I'm able to read 'id' attribute but not 'color' string.
If I define as:

<XmlArray("colors")><XmlArrayItem("color")> Public colors() As String

I'm able to read only the 'color' value. How can I read both ?

Upvotes: 0

Views: 34

Answers (1)

djangojazz
djangojazz

Reputation: 13252

You need to change

<XmlElement("color")> Public defColor As String

to

<XmlText>Public defColor As String

Anything Inside >(here)< is >(Text)<

Upvotes: 1

Related Questions