Java Utililty Methods XML Attribute Get

List of utility methods to do XML Attribute Get

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

Description

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

Method

String getAtrributeValue(Node node, String attribute)
get Atrribute Value
Node _node = node.getAttributes().getNamedItem(attribute);
return getNodeValue(_node);
String getAttr(Element e, String name)
get Attr
String value = e.getAttribute(name);
return ((value == null || value.trim().length() <= 0) ? null : value.trim());
Attr getAttr(Element elem, String name)
get Attr
return elem.getAttributeNode(name);
String getAttr(final Node n, final String attr)
get Attr
final Node attrNode = n.getAttributes().getNamedItem(attr);
if (attrNode != null) {
 return attrNode.getNodeValue();
return null;
String getAttr(final Node n, final String attrName)
Gives the value of a given attribute
String value = null;
if (n.hasAttributes()) {
 final NamedNodeMap map = n.getAttributes();
 for (int i = 0; i < map.getLength(); i++) {
 final Node attrNode = map.item(i);
 if (attrNode.getNodeName().equals(attrName)) {
 value = attrNode.getNodeValue();
return value;
String getAttr(NamedNodeMap attrs, String name)
get Attr
return getAttr(attrs, name, null);
String getAttr(NamedNodeMap attrs, String name, String missing_err)
get Attr
Node attr = attrs == null ? null : attrs.getNamedItem(name);
if (attr == null) {
 if (missing_err == null)
 return null;
 throw new RuntimeException(missing_err + ": missing mandatory attribute '" + name + "'");
String val = attr.getNodeValue();
return val;
...
String getAttr(Node n, String name)
get Attr
if (n == null)
 return null;
Node nn = n.getAttributes().getNamedItem(name);
if (nn != null)
 return nn.getNodeValue();
return null;
String getAttr(Node node, String attr)
get Attr
final NamedNodeMap attributes = node.getAttributes();
final Node nodeAttr = attributes.getNamedItem(attr);
if (nodeAttr != null) {
 return nodeAttr.getTextContent();
return null;
String getAttr(Node node, String name)
get Attr
assert node != null;
try {
 NamedNodeMap attributes = node.getAttributes();
 if (attributes == null)
 throw new Exception("");
 Node attr = attributes.getNamedItem(name);
 if (attr == null)
 throw new Exception("");
...


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