Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlAttribute.Value Property

Gets or sets the value of the node.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

'Declaration
Public Overrides Property Value As String

Property Value

Type: System.String
The value returned depends on the NodeType of the node. For XmlAttribute nodes, this property is the value of attribute.

ExceptionCondition
ArgumentException

The node is read-only and a set operation is called.

The following example displays information on each of the nodes in the attribute collection.

Imports System
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>") 

    'Create an attribute collection. 
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    Console.WriteLine("Display information on each of the attributes... ")
    Dim attr as XmlAttribute
    for each attr in attrColl
       Console.Write("{0}:{1} = {2}", attr.Prefix, attr.LocalName, attr.Value)
       Console.WriteLine("   namespaceURI=" + attr.NamespaceURI)
    next

  end sub
end class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft