System.Xml.XmlNamespaceManager.PopScope C# (CSharp) Méthode

PopScope() public méthode

public PopScope ( ) : bool
Résultat bool
        public virtual bool PopScope() {
            int decl = lastDecl;
            if ( scopeId == 1 ) {
                return false;
            }
            while( nsdecls[decl].scopeId == scopeId ) {
                if ( useHashtable ) {
                    hashTable[nsdecls[decl].prefix] = nsdecls[decl].previousNsIndex;
                }
                decl--;
                Debug.Assert( decl >= 2 );
            }
            lastDecl = decl;
            scopeId--;
            return true;
        }

Usage Example

Exemple #1
0
        private void RemoveDuplicateNamespace(XmlElement elem, XmlNamespaceManager mgr, bool fCheckElemAttrs)
        {
            mgr.PushScope();
            XmlAttributeCollection attributes = elem.Attributes;
            int count = attributes.Count;

            if (fCheckElemAttrs && (count > 0))
            {
                for (int i = count - 1; i >= 0; i--)
                {
                    XmlAttribute attribute = attributes[i];
                    if (attribute.Prefix == this.doc.strXmlns)
                    {
                        string str = mgr.LookupNamespace(attribute.LocalName);
                        if (str == null)
                        {
                            mgr.AddNamespace(attribute.LocalName, attribute.Value);
                        }
                        else if (attribute.Value == str)
                        {
                            elem.Attributes.RemoveNodeAt(i);
                        }
                    }
                    else if ((attribute.Prefix.Length == 0) && (attribute.LocalName == this.doc.strXmlns))
                    {
                        string defaultNamespace = mgr.DefaultNamespace;
                        if (defaultNamespace != null)
                        {
                            if (attribute.Value == defaultNamespace)
                            {
                                elem.Attributes.RemoveNodeAt(i);
                            }
                        }
                        else
                        {
                            mgr.AddNamespace(attribute.LocalName, attribute.Value);
                        }
                    }
                }
            }
            for (XmlNode node = elem.FirstChild; node != null; node = node.NextSibling)
            {
                XmlElement element = node as XmlElement;
                if (element != null)
                {
                    this.RemoveDuplicateNamespace(element, mgr, true);
                }
            }
            mgr.PopScope();
        }
All Usage Examples Of System.Xml.XmlNamespaceManager::PopScope