System.Xml.XmlNodeReaderNavigator.LookupNamespace C# (CSharp) Méthode

LookupNamespace() public méthode

public LookupNamespace ( string prefix ) : String
prefix string
Résultat String
            public String LookupNamespace(string prefix) {
                if( this.bCreatedOnAttribute )
                    return null;
                if ( prefix == "xmlns" ) {
                    return nameTable.Add( XmlReservedNs.NsXmlNs );
                }
                if ( prefix == "xml" ) {
                    return nameTable.Add( XmlReservedNs.NsXml );
                }

                // construct the name of the xmlns attribute
                string attrName;
                if ( prefix == null ) 
                    prefix = string.Empty;
                if ( prefix.Length == 0 ) 
                    attrName = "xmlns";
                else 
                    attrName = "xmlns:" + prefix;

                // walk up the XmlNode parent chain, looking for the xmlns attribute
                XmlNode node = curNode;
                while ( node != null ) {
                    if ( node.NodeType == XmlNodeType.Element ) {
                        XmlElement elem = (XmlElement)node;
                        if ( elem.HasAttributes ) {
                            XmlAttribute attr = elem.GetAttributeNode( attrName );
                            if ( attr != null ) {
                                return nameTable.Add( attr.Value );
                            }
                        }
                    }
                    else if ( node.NodeType == XmlNodeType.Attribute ) {
                        node = ((XmlAttribute)node).OwnerElement;
                        continue;
                    }
                    node = node.ParentNode;
                }
                if ( prefix.Length == 0 ) {
                    return string.Empty;
                }
                return null;
            }