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

LookupPrefix() private méthode

private LookupPrefix ( string namespaceName ) : String
namespaceName string
Résultat String
            internal String LookupPrefix(string namespaceName) {
                if( this.bCreatedOnAttribute || namespaceName == null ) {
                    return null;
                }
                if ( namespaceName == XmlReservedNs.NsXmlNs ) {
                    return nameTable.Add( "xmlns" );
                }
                if ( namespaceName == XmlReservedNs.NsXml ) {
                    return nameTable.Add( "xml" );
                }
                if ( namespaceName == string.Empty ) {
                    return string.Empty;
                }
                // walk up the XmlNode parent chain, looking for the xmlns attribute with namespaceName value
                XmlNode node = curNode;
                while ( node != null ) {
                    if ( node.NodeType == XmlNodeType.Element ) {
                        XmlElement elem = (XmlElement)node;
                        if ( elem.HasAttributes ) {
                            XmlAttributeCollection attrs = elem.Attributes;
                            for ( int i = 0; i < attrs.Count; i++ ) {
                                XmlAttribute a = attrs[i];
                                if ( a.Value == namespaceName ) {
                                   if ( a.Prefix.Length == 0 && a.LocalName == "xmlns" ) {
                                       if ( LookupNamespace( string.Empty ) == namespaceName ) {
                                           return string.Empty;
                                       }
                                   }
                                   else if ( a.Prefix == "xmlns" ) {
                                       string pref = a.LocalName;
                                       if ( LookupNamespace( pref ) == namespaceName ) {
                                           return nameTable.Add( pref );
                                       }
                                   }
                                }
                            }
                        }
                    }
                    else if ( node.NodeType == XmlNodeType.Attribute ) {
                        node = ((XmlAttribute)node).OwnerElement;
                        continue;
                    }
                    node = node.ParentNode;
                }
                return null;
            }