VB.Net/XML/XML Attribute
Версия от 16:40, 26 мая 2010; (обсуждение)
Use XmlElementAttribute and XmlAttributeAttribute
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Public Class MainClass
Public Shared Sub Main()
Dim serialize As XmlSerializer = _
New XmlSerializer(GetType(Product))
Dim MyMovieOrder As Product = _
New Product("PC", 101, 10)
serialize.Serialize(Console.Out, MyMovieOrder)
End Sub
End Class
Public Class Product
<XmlElementAttribute("Name")> Public name As String
<XmlAttributeAttribute("ID")> Public filmId As Integer
<XmlAttributeAttribute("count")> Public quantity As Integer
Public Sub New()
End Sub
Public Sub New(ByVal name As String, _
ByVal filmId As Integer, _
ByVal quantity As Integer)
Me.name = name
Me.filmId = filmId
Me.quantity = quantity
End Sub
End Class