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(final Node xml, final String namespaceURI, final String localName)
Retrieves the desired attribute from the given Node
return xml == null ? null : xmlFindTextNode(xml.getAttributes().getNamedItemNS(namespaceURI, localName));
StringgetAttribute(NamedNodeMap map, String name)
Get a named value from the NamedNodeMap.
String value = "";
try {
    Node node = map.getNamedItem(name);
    if (node != null) {
        value = node.getNodeValue().trim();
} catch (Exception e) {
return value;
StringgetAttribute(NamedNodeMap namedNodeMap, String name)
get Attribute
Node node = namedNodeMap.getNamedItem(name);
if (node == null) {
    return null;
return node.getNodeValue();
StringgetAttribute(NamedNodeMap ruleAttributes, String attributeName)
Get an attribute by name
Node miringRuleNode = ruleAttributes.getNamedItem(attributeName);
String miringRule = miringRuleNode != null ? miringRuleNode.getNodeValue() : null;
return miringRule;
StringgetAttribute(Node aNode, String attributeName)
Returns the value of the named attribute from the given XML node or null if no such attribute exists.
NamedNodeMap attributes = aNode.getAttributes();
if (attributes == null)
    return null;
Node n = attributes.getNamedItem(attributeName);
if (n == null)
    return null;
return n.getNodeValue();
StringgetAttribute(Node attrNode)
get Attribute
StringBuffer value = new StringBuffer();
if (attrNode != null && attrNode.getChildNodes().getLength() > 0) {
    int childCount = attrNode.getChildNodes().getLength();
    for (int i = 0; i < childCount; i++) {
        value.append(attrNode.getChildNodes().item(i).getNodeValue());
return value.toString().trim();
...
StringgetAttribute(Node currentNode, String attributeName)
Gets the attribute value for a Node given the attribute name
NamedNodeMap attrs = currentNode.getAttributes();
return attrs.getNamedItem(attributeName).getNodeValue().trim();
StringgetAttribute(Node element, String attName)
get Attribute
NamedNodeMap attrs = element.getAttributes();
if (attrs == null)
    return null;
Node attN = attrs.getNamedItem(attName);
if (attN == null)
    return null;
return attN.getNodeValue();
StringgetAttribute(Node element, String name, String dflt)
Get the given name-d attribute from the given element.
if (element == null) {
    return dflt;
return getAttribute(element.getAttributes(), name, dflt);
AttrgetAttribute(Node iNode, String iAttributeName)
This method returns the attribute of the given node whose name matches the named value (iAttributeName) and a particular namespace (iNamespaceForAttr).
Logger.getLogger("org.adl.util.debug.validator").entering("DOMTreeUtility", "getAttribute()");
Logger.getLogger("org.adl.util.debug.validator").info("Parent Node: " + iNode.getLocalName());
Logger.getLogger("org.adl.util.debug.validator").info("Node being searched for: " + iAttributeName);
Attr result = null;
if (iNode != null) {
    NamedNodeMap attrList = iNode.getAttributes();
    int numAttr = attrList.getLength();
    Attr currentAttrNode = null;
...