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

RemoveNamespace() public méthode

public RemoveNamespace ( string prefix, string uri ) : void
prefix string
uri string
Résultat void
        public virtual void RemoveNamespace( string prefix, string uri ) {
            if ( uri == null ) {
                throw new ArgumentNullException( "uri" );
            }
            if ( prefix == null ) {
                throw new ArgumentNullException( "prefix" );
            }

            int declIndex = LookupNamespaceDecl( prefix );
            while ( declIndex != -1 ) {
                if ( String.Equals( nsdecls[declIndex].uri, uri ) && nsdecls[declIndex].scopeId == scopeId ) {
                    nsdecls[declIndex].uri = null;
                }
                declIndex = nsdecls[declIndex].previousNsIndex;
            }
        }

Usage Example

        public XmlNode Strip(XmlNode documentElement)
        {
            var namespaceManager = new XmlNamespaceManager(documentElement.OwnerDocument.NameTable);
            foreach (var nspace in namespaceManager.GetNamespacesInScope(XmlNamespaceScope.All))
            {
                namespaceManager.RemoveNamespace(nspace.Key, nspace.Value);
            }

            return documentElement;
        }
All Usage Examples Of System.Xml.XmlNamespaceManager::RemoveNamespace