Java Utililty Methods XML Attribute Get

List of utility methods to do XML Attribute Get

Description

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

Method

StringgetAttribute(Element ownerElem, String attrName)
Gets an attribute value of the given element.
Attr attribute = ownerElem.getAttributeNode(attrName);
return attribute != null ? attribute.getValue() : null;
StringgetAttribute(Element parent, String localName)
get Attribute
if (parent == null) {
    return null;
Attr attribute = parent.getAttributeNode(localName);
if (attribute != null) {
    return attribute.getValue();
} else {
    return null;
...
StringgetAttribute(Element parent, String localName, String namespaceURI)
Returns the value of the named attribute of the current element.
if (parent == null) {
    return null;
Attr attribute;
if (namespaceURI == null) {
    attribute = parent.getAttributeNode(localName);
} else {
    attribute = parent.getAttributeNodeNS(namespaceURI, localName);
...
StringgetAttribute(File file, String attr)
get Attribute
Logger logger = Logger.getLogger("eu.excitementproject.eop.util.runner.ConfigFileUtils:getAttribute");
logger.info("Looking for a value for attribute: " + attr);
Document configDoc = parse(file);
NodeList sectionList = configDoc.getElementsByTagName(sectionTag);
String value = findAttributeRec(sectionList, attr);
if (value != null) {
    logger.info("Value for attribute " + attr + " : " + value);
return value;
StringgetAttribute(final List elements, final int index)
get Attribute
final Element element = elements.get(index);
final NamedNodeMap attrs = element.getAttributes();
final Node item = attrs.getNamedItem("value");
if (item != null) {
    return item.getNodeValue();
return null;
AttrgetAttribute(final Node iNode, final String iAttributeName)
This method returns the attribute of the given node whose name matches the named value (iAttributeName) and a particular namespace (iNamespaceForAttr).
Attr result = null;
if (iNode != null) {
    NamedNodeMap attrList = iNode.getAttributes();
    int numAttr = attrList.getLength();
    Attr currentAttrNode = null;
    String currentNodeName = null;
    for (int k = 0; k < numAttr; k++) {
        currentAttrNode = (Attr) attrList.item(k);
...
StringgetAttribute(final Node n, final String attrName, final String defaultValue)
get Attribute
if (n.getAttributes().getNamedItem(attrName) != null) {
    return ((Attr) n.getAttributes().getNamedItem(attrName)).getValue();
return defaultValue;
intgetAttribute(final Node node, final String attribname, final int def)
get Attribute
final String attr = getAttributeValue(node, attribname);
if (attr != null) {
    return Integer.parseInt(attr);
} else {
    return def;
StringgetAttribute(final Node node, final String attributeName)
get Attribute
final NamedNodeMap tmpMap = node.getAttributes();
if (tmpMap == null) {
    return null;
final Node tmpNode = tmpMap.getNamedItem(attributeName);
if (tmpNode == null) {
    return null;
return tmpNode.getNodeValue();
NodegetAttribute(final Node node, final String name)
get Attribute
if (node == null) {
    throw new IllegalArgumentException("The node is null.");
} else if (name == null || name.isEmpty()) {
    throw new IllegalArgumentException("The attribute's name is null or empty.");
} else {
    final NamedNodeMap namedNodeMap = node.getAttributes();
    if (namedNodeMap != null) {
        return namedNodeMap.getNamedItem(name);
...