Java Utililty Methods XML Attribute Read

List of utility methods to do XML Attribute Read

Description

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

Method

longgetLong(Node xmlNode, String attributeLabel)
get Long
return Long.parseLong(xmlNode.getAttributes().getNamedItem(attributeLabel).getNodeValue());
longgetLong(String attrName, Map runtimeAttributes, Node docElement)
Get a long value.
String stringValue = getStringValue(attrName, runtimeAttributes, docElement);
if (stringValue != null) {
    try {
        return Long.parseLong(stringValue);
    } catch (NumberFormatException e) {
throw new RuntimeException(
...
LonggetLongAttribute(NamedNodeMap namedNodeMap, String name)
get Long Attribute
String value = getAttribute(namedNodeMap, name);
if (value == null) {
    return null;
} else {
    return Long.valueOf(value);
LonggetLongAttribute(String name, Element el)
Gets the value of the DOM element's attribute with the given name as a Long, or null if the value is not a long.
return stringToLong(getAttribute(name, el));
StringgetNameAttribute(final Node aNode)
Retrieves the value of the name attribute of the supplied Node.
return getNamedAttribute(aNode, NAME_ATTRIBUTE);
StringgetNamedAttribute(final Node aNode, final String attributeName)
get Named Attribute
if (aNode == null) {
    return null;
final NamedNodeMap attributes = aNode.getAttributes();
if (attributes != null) {
    final Node nameNode = attributes.getNamedItem(attributeName);
    if (nameNode != null) {
        return nameNode.getNodeValue().trim();
...
AttrgetNewAttribute(Element element, String name)
get New Attribute
String safeName = name.replaceAll("\\$", "::");
return element.getOwnerDocument().createAttribute(safeName);
StringgetNSPrefixFromNSAttr(Attr a)
Fetch the non-null namespace prefix from a Attr that declares a namespace.
assert a != null;
assert isNSAttribute(a);
if (a.getPrefix() == null) {
    return "";
return a.getName().substring(a.getPrefix().length() + 1);
StringgetNullableAttribute(final Element node, final String attributeName)
Get the attribute value under the specified name from the given element.
if (node.hasAttribute(attributeName)) {
    return node.getAttribute(attributeName);
return null;
StringgetNullSafe(NamedNodeMap attr, String key)
Get the node value of the attribute key from the set attr .
Node node = attr.getNamedItem(key);
return node != null ? node.getNodeValue() : null;