Java tutorial
//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); } // 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); } } }