XmlNamespaceManager.LookupPrefix Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Finds the prefix declared for the given namespace URI.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- uri
- Type: System.String
The namespace to resolve for the prefix.
Return Value
Type: System.StringThe matching prefix. If there is no mapped prefix, the method returns String.Empty. If a null value is supplied, then Nothing is returned.
Implements
IXmlNamespaceResolver.LookupPrefix(String)This method finds the mapped prefix by walking the stack (that is, it looks globally). The supplied string must be atomized for the lookup to succeed. In other words, the supplied string object must exist in the XmlNamespaceManager's NameTable.
The returned string is also atomized. For more information on atomized strings, see XmlNameTable.
Dim output As New StringBuilder() ' Create the XmlNamespaceManager. Dim nt As New NameTable() Dim nsmgr As New XmlNamespaceManager(nt) ' Add prefix/namespace pairs to the XmlNamespaceManager. nsmgr.AddNamespace("", "www.wideworldimporters.com") 'Adds a default namespace. nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe") Dim prefix As String = nsmgr.LookupPrefix("www.wideworldimporters.com/europe") output.AppendLine((" Before removing prefix: " + prefix)) nsmgr.RemoveNamespace(prefix, "www.wideworldimporters.com/europe") output.Append((" Before removing prefix: " + nsmgr.LookupPrefix("www.wideworldimporters.com/europe"))) OutputTextBlock.Text = output.ToString()