Microsoft Docs

XmlNodeReader.NamespaceURI Property

Gets the namespace URI of the current node.

Syntax

public override string NamespaceURI { get; }

Remarks

The NamespaceURI property returns the fully qualified namespace name of the current node. If the node does not have a namespace, an empty string is returned.

Examples

using System;
using System.Xml;

class Program
{
    static void Main()
    {
        string xml = @"<root xmlns:ex='http://example.com'>
                          <ex:child>Value</ex:child>
                       </root>";

        using (XmlReader reader = XmlReader.Create(new System.IO.StringReader(xml)))
        {
            XmlNodeReader nodeReader = new XmlNodeReader(new XmlDocument());
            nodeReader.Read();
            Console.WriteLine($""Current node: {nodeReader.Name}"");
            Console.WriteLine($""NamespaceURI: {nodeReader.NamespaceURI}"");
        }
    }
}

See also