System.Xml.XmlNamedNodeMap.RemoveNamedItem C# (CSharp) Méthode

RemoveNamedItem() public méthode

public RemoveNamedItem ( String name ) : XmlNode
name String
Résultat XmlNode
        public virtual XmlNode RemoveNamedItem(String name) {
            int offset = FindNodeOffset(name);
            if (offset >= 0) {
                return RemoveNodeAt( offset );
            }
            return null;
        }

Same methods

XmlNamedNodeMap::RemoveNamedItem ( String localName, String namespaceURI ) : XmlNode

Usage Example

        /// <summary>Removes attributes, comments, and processing instructions. </summary>
        private static void  clean(System.Xml.XmlElement elem)
        {
            System.Xml.XmlNodeList children = elem.ChildNodes;
            for (int i = 0; i < children.Count; i++)
            {
                System.Xml.XmlNode child = children.Item(i);
                if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.ProcessingInstruction || System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Comment)
                {
                    elem.RemoveChild(child);
                }
                else if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Element)
                {
                    clean((System.Xml.XmlElement)child);
                }
            }

            System.Xml.XmlNamedNodeMap attributes = (System.Xml.XmlAttributeCollection)elem.Attributes;
            //get names
            System.String[] names = new System.String[attributes.Count];
            for (int i = 0; i < names.Length; i++)
            {
                names[i] = attributes.Item(i).Name;
            }
            //remove by name
            for (int i = 0; i < names.Length; i++)
            {
                attributes.RemoveNamedItem(names[i]);
            }
        }
All Usage Examples Of System.Xml.XmlNamedNodeMap::RemoveNamedItem