Java Utililty Methods XML Attribute Exist

List of utility methods to do XML Attribute Exist

Description

The list of methods to do XML Attribute Exist are organized into topic(s).

Method

booleanhasAttribute(Element e, String s)
has Attribute
return e.getAttributes().getNamedItem(s) != null;
booleanhasAttribute(Element ele, String attrName)
judge whether element has an attribute named attrName
NamedNodeMap map = ele.getAttributes();
for (int i = 0; i < map.getLength(); i++) {
    Node attr = map.item(i);
    if (attr.getNodeName().equalsIgnoreCase(attrName)) {
        return true;
return false;
...
booleanhasAttribute(Element element, String attribute)
has Attribute
String s = element.getAttribute(attribute);
if (s == null || "".equals(s)) {
    return false;
} else {
    return true;
BooleanhasAttribute(Element element, String namespace, String name)
Check if an Element has an attribute.
String value = getAttribute(element, namespace, name);
return (value != null);
booleanhasAttribute(Element element, String value)
has Attribute
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;
...
booleanhasAttribute(final Node node, final String name)
Indicates if the passed node has the named atribute
if (name == null || node == null)
    return false;
final NamedNodeMap nnm = node.getAttributes();
for (int i = 0; i < nnm.getLength(); i++) {
    Attr attr = (Attr) nnm.item(i);
    if (attr.getName().equalsIgnoreCase(name)) {
        return true;
return false;
booleanhasAttribute(final Node node, final String name)
Determines if the passed node has an attribute with the passed name
return getAttributeByName(node, name, null) != null;
booleanhasAttribute(Node n, String attr)
has Attribute
NamedNodeMap attrs = n.getAttributes();
if (attrs == null)
    return false;
Node ret = attrs.getNamedItem(attr);
if (ret == null)
    return false;
else
    return true;
...
booleanhasAttribute(Node node, String attributeName)
has Attribute
return (node != null && node.getAttributes() != null
        && node.getAttributes().getNamedItem(attributeName) != null);
booleanhasAttribute(Node node, String attributeName)
has Attribute
return (node != null && node.hasAttributes() && node.getAttributes().getNamedItem(attributeName) != null);