Here you can find the source of removeAllAttributes(Node node, String attrName)
public static void removeAllAttributes(Node node, String attrName)
//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); } } }