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

StringgetAttrNS(Node node, String nameSpace, String attrName)
get Attr NS
final NamedNodeMap attrNode = node.getAttributes();
if (attrNode == null) {
    return null;
final Node valueNode = attrNode.getNamedItemNS(nameSpace, attrName);
if (valueNode == null) {
    return null;
return valueNode.getNodeValue();
Attr[]getAttrs(Element elem)
get Attrs
NamedNodeMap attrMap = elem.getAttributes();
Attr[] attrArray = new Attr[attrMap.getLength()];
for (int i = 0; i < attrMap.getLength(); i++)
    attrArray[i] = (Attr) attrMap.item(i);
return attrArray;
Attr[]getAttrs(Element elem)
get Attrs
NamedNodeMap attrMap = elem.getAttributes();
Attr[] attrArray = new Attr[attrMap.getLength()];
for (int i = 0; i < attrMap.getLength(); i++)
    attrArray[i] = (Attr) attrMap.item(i);
return attrArray;
StringgetAttrsAsString(Node node)
get Attrs As String
if (node == null)
    return "";
NamedNodeMap attrs = node.getAttributes();
StringBuilder val = new StringBuilder();
if (attrs != null) {
    for (int i = 0; i < attrs.getLength(); i++) {
        Node nval = attrs.item(i);
        if (nval != null) {
...
StringgetAttrString(Element elem, String localName)
Returns the String value of the unqualified attribute with the given local name belonging to the given element, or null if the attribute is not present.
Attr attr = elem.getAttributeNodeNS(null, localName);
String value = (attr != null) ? attr.getValue() : null;
return value;
StringgetAttrVal(final NamedNodeMap nnm, final String name)
Return the attribute value of the named attribute from the given map.
Node nmAttr = nnm.getNamedItem(name);
if ((nmAttr == null) || (absent(nmAttr.getNodeValue()))) {
    return null;
return nmAttr.getNodeValue();
StringgetAttrValue(NamedNodeMap attrs, String attrName)
get Attr Value
if (attrs == null || attrName == null) {
    return null;
String attrValue = null;
Node attrNode = attrs.getNamedItem(attrName);
if (attrNode == null || Node.ATTRIBUTE_NODE != attrNode.getNodeType()) {
    return null;
attrValue = attrNode.getNodeValue();
return attrValue;
StringgetAttrvalue(Node item, String name, boolean ignoreNs)
get Attrvalue
NamedNodeMap attributes = item.getAttributes();
int numAttrs = attributes.getLength();
for (int i = 0; i < numAttrs; i++) {
    Attr attr = (Attr) attributes.item(i);
    String attrName = attr.getNodeName();
    String NSName = attr.getNamespaceURI();
    if (ignoreNs) {
        if ((attrName.indexOf(":" + name) != -1) || (name.equals(attrName)))
...
StringgetAttrValue(Node n, String name)
get Attr Value
NamedNodeMap attrs = n.getAttributes();
return (attrs.getNamedItem(name) != null) ? attrs.getNamedItem(name).getNodeValue() : null;
StringgetAttrValuesByName(Element ele, String attributeName)
get Attr Values By Name
return ele.getAttribute(attributeName);