XmlAttribute.LocalName Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the local name of the node.

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

Public Overrides ReadOnly Property LocalName As String

Property Value

Type: System.String

The name of the attribute node with the prefix removed. In the following example <book bk:genre= 'novel'>, the LocalName of the attribute is genre.

If the node does not have a prefix, LocalName is the same as Name.

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>" & _

    '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)

  end sub
end class

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top