Has Attribute
import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Utils { public static boolean hasAttribute(Element element, String value) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node node = attributes.item(i); if (value.equals(node.getNodeValue())) { return true; } } return false; } }