Reputation: 581
I am wondering how to get the following format on a single property including a type. Like so:
**<Productname type ="Drinks">coke<Productname>**
What have I tried?
<XmlRoot("Productname1")> _
Public Class Productname
<XmlAttribute("Type")> Public type As String = "Drinks"
Private m_Productname As String
Public Property Productname() As String
Get
Return m_Productname
End Get
Set(ByVal value As String)
m_Productname = value
End Set
End Property
End Class
but the following will happen with my code
<Productname1 Type="Drinks">
<Productname >coke</Productname >
</Productname1>
I just don't understand how this works and I have been searching for a while now.
Upvotes: 1
Views: 44
Reputation: 2660
Try this, it should work.
Public Class ProductName
<XmlAttribute("Type")>
Property type As String = "Drinks"
<XmlText()>
Property Text As String = "Coke"
End Class
Upvotes: 1