LookupNamespace Method
Collapse the table of content
Expand the table of content

XmlNamespaceManager.LookupNamespace Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the namespace URI for the specified prefix.

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

'Declaration
Public Overridable Function LookupNamespace ( _
	prefix As String _
) As String

Parameters

prefix
Type: System.String
The prefix whose namespace URI you want to resolve. To match the default namespace, pass String.Empty.

Return Value

Type: System.String
Returns the namespace URI for prefix or Nothing if there is no mapped namespace. The returned string is atomized.
For more information on atomized strings, see XmlNameTable.

Implements

IXmlNamespaceResolver.LookupNamespace(String)


Dim output As New StringBuilder()

Dim xmlFrag As String = _
      "<root>" & _
        "<data>" & _
         "<items>" & _
          "<item id='1'>" & _
          "</item>" & _
         "</items>" & _
        "</data>" & _
        "</root>"

Using reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag))
    Dim nsmanager As New XmlNamespaceManager(reader.NameTable)
    nsmanager.AddNamespace("msbooks", "www.microsoft.com/books")
    nsmanager.PushScope()
    nsmanager.AddNamespace("msstore", "www.microsoft.com/store")

    Dim prefix As String
    For Each prefix In nsmanager
        output.AppendLine(("Prefix" + prefix + _
                           " Namespace=" + nsmanager.LookupNamespace(prefix)))
    Next prefix
End Using
OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft