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

XmlReader.LookupNamespace Method (String)


When overridden in a derived class, resolves a namespace prefix in the current element's scope.

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

abstract LookupNamespace : 
        prefix:string -> string


Type: System.String

The prefix whose namespace URI you want to resolve. To match the default namespace, pass an empty string.

Return Value

Type: System.String

The namespace URI to which the prefix maps or null if no matching prefix is found.

Exception Condition

An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”

In the following XML string, if the reader is positioned on the href attribute, the prefix a is resolved by calling reader.LookupNamespace("a"). The returned string is urn:456.

<root xmlns:a="urn:456">
  <ref href="a:b"/>

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft