System.Xml.DocumentXPathNavigator.GetNamespace C# (CSharp) Méthode

GetNamespace() public méthode

public GetNamespace ( string name ) : string
name string
Résultat string
        public override string GetNamespace(string name) {
            XmlNode node = source;
            while (node != null
                   && node.NodeType != XmlNodeType.Element) {
                XmlAttribute attribute = node as XmlAttribute;
                if (attribute != null) {
                    node = attribute.OwnerElement;
                }
                else {
                    node = node.ParentNode;
                }
            }

            XmlElement element = node as XmlElement;
            if (element != null) {
                string localName;
                if (name != null
                    && name.Length != 0) {
                    localName = name;
                }
                else {
                    localName = document.strXmlns;
                }
                string namespaceUri = document.strReservedXmlns;

                do
                {
                    XmlAttribute attribute = element.GetAttributeNode(localName, namespaceUri);
                    if (attribute != null) {
                        return attribute.Value;
                    }
                    element = element.ParentNode as XmlElement;
                }
                while (element != null);
            }

            if (name == document.strXml) {
                return document.strReservedXml;
            }
            else if (name == document.strXmlns) {
                return document.strReservedXmlns;
            }
            return string.Empty;
        }