Here you can find the source of removeAllAttributes(Element element)
public static void removeAllAttributes(Element element)
//package com.java2s; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { public static void removeAllAttributes(Element element) { // A NamedNodeMap is live. NamedNodeMap attrs = element.getAttributes(); int attrCount = attrs.getLength(); for (int i = attrCount - 1; i >= 0; --i) { Attr attr = (Attr) attrs.item(i); attrs.removeNamedItemNS(attr.getNamespaceURI(), attr.getLocalName()); }/*from w ww.jav a 2 s . c o m*/ } }