Class Code:
Code:
Public Class Product
Public Property ProductID() As String
Public Property ProductName() As String
Public Property ProductPrice() As Decimal
Public Property ProductExpDate() As Date
End Class
Code:
Private Sub arraytoxml_Click(sender As Object, e As EventArgs) Handles arraytoxml.Click
Dim Products() As Product =
{New Product With
{.ProductID = 3, .ProductName = "Product A",
.ProductPrice = 8.75,
.ProductExpDate = #2/2/2009#},
New Product With
{.ProductID = 4, .ProductName = "Product B",
.ProductPrice = 19.5},
New Product With
{.ProductID = 5, .ProductName = "Product C",
.ProductPrice = 21.25,
.ProductExpDate = #12/31/2010#}}
End Sub
How can I Generate the corresponding XML ?. Thank you
Solved It !!!!. It works like this :
Code:
Private Sub arraytoxml_Click(sender As Object, e As EventArgs) Handles arraytoxml.Click
Dim Products() As Product =
{New Product With
{.ProductID = 3, .ProductName = "Product A",
.ProductPrice = 8.75,
.ProductExpDate = #2/2/2009#},
New Product With
{.ProductID = 4, .ProductName = "Product B",
.ProductPrice = 19.5},
New Product With
{.ProductID = 5, .ProductName = "Product C",
.ProductPrice = 21.25,
.ProductExpDate = #12/31/2010#}}
Dim prods = <Products>
<%= From prod In Products
Select <Product>
<ID><%= prod.ProductID %></ID>
<Name><%= prod.ProductName %></Name>
<Price><%= prod.ProductPrice %></Price>
<ExpirationDate>
<%= prod.ProductExpDate %></ExpirationDate>
</Product> %>
</Products>
MsgBox(prods.ToString)
End Sub
XML :
Code:
<Products>
<Product>
<ID>3</ID>
<Name>Product A</Name>
<Price>8.75</Price>
<ExpirationDate>2009-02-02T00:00:00</ExpirationDate>
</Product>
<Product>
<ID>4</ID>
<Name>Product B</Name>
<Price>19.5</Price>
<ExpirationDate>0001-01-01T00:00:00</ExpirationDate>
</Product>
<Product>
<ID>5</ID>
<Name>Product C</Name>
<Price>21.25</Price>
<ExpirationDate>2010-12-31T00:00:00</ExpirationDate>
</Product>
</Products>
Solved It !!!!.