XmlReader.LocalName Property

When overridden in a derived class, gets the local name of the current node.

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

Public MustOverride ReadOnly Property LocalName As String

Property Value

Type: System.String
The name of the current node with the prefix removed. For example, LocalName is book for the element <bk:book>.
For node types that do not have a name (like Text, Comment, and so on), this property returns String.Empty.

Dim output As New StringBuilder()

Dim xmlString As String = _
        "<book xmlns:bk='urn:samples'>" & _
            "<title>Pride And Prejudice</title>" & _
            "<bk:genre>novel</bk:genre>" & _

' Create an XmlReader
Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString))

    ' Parse the file.  If they exist, display the prefix and 
    ' namespace URI of each node.
    While reader.Read()
        If reader.IsStartElement() Then
            If reader.Prefix = String.Empty Then
                output.Append("<" + reader.LocalName + ">")
                output.Append("<" + reader.Prefix + ":" + reader.LocalName + ">")
                output.AppendLine(" The namespace URI is " + reader.NamespaceURI)
            End If
        End If
    End While
End Using

OutputTextBlock.Text = output.ToString()


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions