List of utility methods to do XML Element Attribute Get
String | getAttributeValue(Element elem, String name) Returns the attribute value for the attribute with the specified name. Attr attr = elem.getAttributeNodeNS(null, name);
return (attr == null) ? null : attr.getValue();
|
boolean | getBooleanAttribute(Element el, String name) get Boolean Attribute String s = el.getAttribute(name); if (s == null || "0".equals(s)) { return false; if ("1".equals(s)) { return true; return new Boolean(s).booleanValue(); ... |
int | getIntAttribute(Element el, String name) get Int Attribute String s = el.getAttribute(name); if (s != null && s.length() > 0) { return Integer.parseInt(s); return 0; |
void | processAnyAttributes(Element element, Map Processes any attributes and add them into the element. for (Map.Entry<QName, String> attribute : anyAttributes.entrySet()) { String localName = attribute.getKey().getLocalPart(); String prefix = attribute.getKey().getPrefix(); String namespace = attribute.getKey().getNamespaceURI(); element.setAttributeNS(namespace, prefix + ":" + localName, attribute.getValue()); |
String | getNodeAttrValue(Element parent, String nodeName, String attrName) get Node Attr Value try { return ((Element) parent.getElementsByTagName(nodeName).item(0)) .getAttribute(attrName); } catch (Exception e) { e.printStackTrace(); return null; |