Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XmlNamespaceManager.LookupPrefix Method

Finds the prefix declared for the given namespace URI.

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

public virtual string LookupPrefix (
	string uri
public String LookupPrefix (
	String uri
public function LookupPrefix (
	uri : String
) : String
Not applicable.



The namespace to resolve for the prefix.

Return Value

The matching prefix. If there is no mapped prefix, the method returns String.Empty. If a null value is supplied, then a null reference (Nothing in Visual Basic) is returned.

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.

The following example removes a namespace from the namespace manager.

String prefix = nsmgr.LookupPrefix("www.wideworldimporters.com/europe");
nsmgr.RemoveNamespace(prefix, "www.wideworldimporters.com/europe");

String prefix = nsMgr.LookupPrefix("www.wideworldimporters.com/europe");
nsMgr.RemoveNamespace(prefix, "www.wideworldimporters.com/europe");

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

© 2014 Microsoft. All rights reserved.