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

intreadInt(Node node, String attributeName, int def)
read Int
try {
    return Integer.parseInt(node.getAttributes().getNamedItem(attributeName).getNodeValue());
} catch (Exception ex) {
    return def;
intreadIntAttr(Element element, String attributeName, int defaultValue)
read Int Attr
String attributeValue = element.getAttribute(attributeName);
try {
    return Integer.parseInt(attributeValue);
} catch (NumberFormatException e) {
    return defaultValue;
intreadIntegerAttribute(Element elem, String name, int defaultValue)
read Integer Attribute
int back = defaultValue;
String str = elem.getAttribute(name);
if (str != null) {
    if (str.length() > 0) {
        back = Integer.parseInt(str);
return back;
...
voidreadNodeAttributes(Element elem, Object[] map)
Read the attributes of elem.
NamedNodeMap attrMap = elem.getAttributes();
for (int i = 0; i < attrMap.getLength(); i++) {
    Attr attr = (Attr) attrMap.item(i);
    String key = attr.getName();
    for (int j = 0; j < map.length; j += 2) {
        if (map[j].equals(key)) {
            map[j + 1] = convert(attr.getValue(), (Class) map[j + 1]);