Hi Friends,
Dim str As String = "<?xml version='1.0'?><catalog><things><gadgets>Watch</gadgets></things><book><Novel><price>10</price></Novel><Novel><price>15</price></Novel></book></catalog>"
Dim catalog As catalog = New catalog()
Dim serializer As New XmlSerializer(GetType(catalog))
Using reader As TextReader = New StringReader(str)
catalog = serializer.Deserialize(reader)
Dim bookprice As String = catalog.book(0).price
End Using
Public Class catalog
Private thingsField As catalogThings
Private bookField() As catalogNovel
Public Property things() As catalogThings
Get
Return Me.thingsField
End Get
Set(value As catalogThings)
Me.thingsField = value
End Set
End Property
Public Property book() As catalogNovel()
Get
Return Me.bookField
End Get
Set(value As catalogNovel())
Me.bookField = value
End Set
End Property
End Class
Public Class catalogThings
Private gadgetsField As String
Public Property gadgets() As String
Get
Return Me.gadgetsField
End Get
Set(value As String)
Me.gadgetsField = value
End Set
End Property
End Class
Public Class catalogNovel
Private priceField As Integer
Public Property price() As Integer
Get
Return Me.priceField
End Get
Set(value As Integer)
Me.priceField = value
End Set
End Property
End Class
I am getting error "Index was outside the bounds of the array.
How to get both prices.
Thanks in advance.