Java XML Attribute Remove removeAllAttributes(Node node, String attrName)

Here you can find the source of removeAllAttributes(Node node, String attrName)

Description

remove All Attributes

License

Open Source License

Declaration

public static void removeAllAttributes(Node node, String attrName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.*;

public class Main {
    public static void removeAllAttributes(Node node, String attrName) {

        // check if this node contains the attribute and remove it
        NamedNodeMap attrs = node.getAttributes();
        if (attrs != null && attrs.getNamedItem(attrName) != null) {
            attrs.removeNamedItem(attrName);
        }/*from w w  w. ja  v a2  s  . c  o m*/

        // process recursively all children
        NodeList list = node.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            // Get child node
            Node childNode = list.item(i);

            // Visit child node
            removeAllAttributes(childNode, attrName);
        }
    }
}

Related

  1. removeAllAttributes(Element element)
  2. removeAllAttributes(Element element)
  3. removeAllAttributes(Element element)
  4. removeAllSubNodesExceptAttributes(Node n)
  5. removeAttribute(Element elem, String name)
  6. removeAttribute(Element element, String name)
  7. removeAttribute(final Attr attributeNode)