Java Utililty Methods XML Attribute from Node

List of utility methods to do XML Attribute from Node

Description

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

Method

DategetXMLDate(Element e, String attrName)
get XML Date
String s = e.getAttribute(attrName);
if (s == null || s.length() == 0)
    return null;
try {
    return parseDate(s);
} catch (Exception exc) {
    return null;
intgetXMLInt(Element e, String attrName)
get XML Int
try {
    return Integer.parseInt(e.getAttribute(attrName));
} catch (Exception exc) {
    return -1;
intgetXMLInt(Element e, String attrName)
get XML Int
try {
    return Integer.parseInt(e.getAttribute(attrName));
} catch (Exception exc) {
    return -1;
StringgetXmlNodeAttribute(String attributeName, NodeList nodeList)
Extract the node string representation.
String retObj = null;
if (nodeList != null && nodeList.getLength() > 0) {
    Element element = (Element) nodeList.item(0);
    retObj = element.getAttribute(attributeName);
return retObj;
StringgetXmlNodeAttributeValue(Node NN, String AttrName)
Returns the String value of the given attribue of an xml node
if (NN == null)
    return null;
if (AttrName == null)
    return null;
if (AttrName.length() < 1)
    return null;
NamedNodeMap atts = NN.getAttributes();
if (atts != null) {
...
BooleangetYesNoAttrVal(final NamedNodeMap nnm, final String name)
The attribute value of the named attribute in the given map must be absent or "yes" or "no".
String val = getAttrVal(nnm, name);
if (val == null) {
    return null;
if ((!"yes".equals(val)) && (!"no".equals(val))) {
    throw new SAXException("Invalid attribute value: " + val);
return new Boolean("yes".equals(val));
...
booleanhasAttribByName(Element node, String name)
has Attrib By Name
return node.hasAttribute(name);
StringparseAttribute(Node lnNode, String attributeName)
parse Attribute
NamedNodeMap attributes = lnNode.getAttributes();
String attributeValue = null;
if (attributes != null) {
    Node attributeNode;
    for (int i = 0; i < attributes.getLength(); i++) {
        attributeNode = attributes.item(i);
        if (attributeNode.getNodeName().equals(attributeName))
            attributeValue = attributeNode.getNodeValue();
...
MapparseAttribute(NodeList abtList)
parse Attribute
Map map = new HashMap();
try {
    for (int i = 0; i < abtList.getLength(); i++) {
        Node abt = abtList.item(i);
        if (abt.getNodeType() == 1) {
            map.put(abt.getNodeName(), abt.getTextContent().replace("'", "").replace("?", ""));
} catch (Exception e) {
    e.printStackTrace();
return map;
PropertiesparseAttributes(Node n)
parse Attributes
return parseAttributes(n, null);