List of utility methods to do XML Attribute Get
String | getAttr(Node node, String name, String defaultValue) get Attr String result = defaultValue; if (node != null && node.getAttributes() != null && node.getAttributes().getNamedItem(name) != null) result = node.getAttributes().getNamedItem(name).getNodeValue(); return result; |
boolean | getAttrBool(Node n, String name) get Attr Bool if (n == null) return false; Node nn = n.getAttributes().getNamedItem(name); if (nn == null) return false; String value = nn.getNodeValue(); if (value == null) return false; ... |
Date | getAttrDate(Element elem, String localName) Returns the Date value of the unqualified attribute with the given local name belonging to the given element, or null if the attribute is not present. String str = getAttrString(elem, localName); if (str != null) { try { return dateFormat.parse(str); } catch (ParseException ignored) { return null; ... |
String | getAttrib(NamedNodeMap attribs, String name) get Attrib return attribs.getNamedItem(name).getNodeValue();
|
Boolean | getAttribAsBoolean(Element e, String name, Boolean dft) get Attrib As Boolean if (getAttribute(e, name) == null) return dft; else return Boolean.parseBoolean(getAttribute(e, name)); |
Float | getAttribAsFloat(Element e, String name, Float dft) get Attrib As Float String num = getAttribute(e, name); return num.equals("") ? dft : Float.parseFloat(num); |
boolean | getAttribBoolean(Element ele, String name) Parses the given attribute of this tag and returns it as a boolean. String sval = ele.getAttribute(name); return sval.toLowerCase().equals("true"); |
String | getAttribByName(Element node, String name) get Attrib By Name return node.getAttribute(name);
|
float | getAttribFloat(Element ele, String name) Parses the given attribute of this tag and returns it as a float String sval = ele.getAttribute(name); float val = 0.0f; try { val = Float.parseFloat(sval); } catch (Exception e) { return val; |
int | getAttribIntHex(Element ele, String name) Parses the given attribute of this tag as a hexadecimal encoded string and returns it as an int String sval = ele.getAttribute(name); int val = 0; try { val = Integer.parseInt(sval, 16); } catch (Exception e) { return val; |