Java Utililty Methods XML Attribute Exist

List of utility methods to do XML Attribute Exist

  1. HOME
  2. Java
  3. X
  4. XML Attribute Exist

Description

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

Method

boolean hasAttribute(Element e, String s)
has Attribute
return e.getAttributes().getNamedItem(s) != null;
boolean hasAttribute(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;
...
boolean hasAttribute(Element element, String attribute)
has Attribute
String s = element.getAttribute(attribute);
if (s == null || "".equals(s)) {
 return false;
} else {
 return true;
Boolean hasAttribute(Element element, String namespace, String name)
Check if an Element has an attribute.
String value = getAttribute(element, namespace, name);
return (value != null);
boolean hasAttribute(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;
...
boolean hasAttribute(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;
boolean hasAttribute(final Node node, final String name)
Determines if the passed node has an attribute with the passed name
return getAttributeByName(node, name, null) != null;
boolean hasAttribute(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;
...
boolean hasAttribute(Node node, String attributeName)
has Attribute
return (node != null && node.getAttributes() != null
 && node.getAttributes().getNamedItem(attributeName) != null);
boolean hasAttribute(Node node, String attributeName)
has Attribute
return (node != null && node.hasAttributes() && node.getAttributes().getNamedItem(attributeName) != null);


AltStyle によって変換されたページ (->オリジナル) /