Use XmlElementAttribute and XmlAttributeAttribute : XML Attribute « XML « VB.Net






Use XmlElementAttribute and XmlAttributeAttribute

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

           
         
    
  








Related examples in the same category

1.Get the value of the ISBN attribute.
2.Gets an XmlAttributeCollection containing the list of attributes for this node.
3.Returns the value for the attribute with the specified name.
4.Returns the XmlAttribute with the specified name.
5.Whether the current node has any attributes.
6.Removes all specified attributes and children of the current node.
7.Removes all specified attributes from the element. Default attributes are not removed.
8.Removes an attribute by name.
9.Removes an attribute with the specified local name and namespace URI
10.Removes the attribute node with the specified index from the element
11.Removes the XmlAttribute specified by the local name and namespace URI
12.Adds the specified XmlAttribute.
13.Gets an XmlAttributeCollection containing the attributes of this node.
14.Removes all the child nodes and/or attributes of the current node.
15.Writes an attribute with the specified local name, namespace URI, and value.
16.Extensions.Attributes returns a collection of the attributes of every element in the source collection.
17.Extensions.Attributes returns a filtered collection of the attributes
18.Extensions.Remove removes every attribute in the source collection from its parent element.
19.Cast attribute value to nullable integer
20.Check Nothing for attribute getting
21.Get attribute and parse to Integer
22.Attributes are not nodes, so will not be returned by the descendants axis
23.Get attribute with namespace
24.Gets the first attribute of this element.
25.XName Class represents a name of an XML element or attribute.