List of utility methods to do XML Node Attribute Get
String | getAttrOfName(Node node, String string) get Attr Of Name NamedNodeMap attributes = node.getAttributes(); Node namedItem = attributes.getNamedItem(string); if (namedItem == null) { return null; return namedItem.getNodeValue(); |
String | getAttribute(Node node, String name) Extracts from node the attribute with the specified name. if (node == null) return null; Node attribute = node.getAttributes().getNamedItem(name); return (attribute == null) ? null : attribute.getNodeValue().trim(); |
String | getAttributeValue(Node node, String attributeName) get Attribute Value Node n = node.getAttributes().getNamedItem(attributeName); if (n == null) return null; else return n.getTextContent(); |
String | getAttributeValue(Node node, String attributeName) get Attribute Value if (node == null || attributeName == null) { return null; Node attrNode = node.getAttributes().getNamedItem(attributeName); return attrNode != null ? attrNode.getNodeValue() : null; |
Integer | getAttributeValueAsInt(Node node, String attributeName) get Attribute Value As Int if (node == null || attributeName == null) { return null; try { return Integer.valueOf(Integer.parseInt(getAttributeValue(node, attributeName))); } catch (NumberFormatException e) { return null; ... |
String | getElementAttr(Node element, String attrName) get Element Attr if (element.getAttributes() != null) { for (int i = 0; i < element.getAttributes().getLength(); i++) { Node child = element.getAttributes().item(i); if (child.getNodeName().equals(attrName)) { return child.getNodeValue(); return null; |
String | getElementAttr(Node element, String attrName) get Element Attr for (int i = 0; i < element.getAttributes().getLength(); i++) { Node child = element.getAttributes().item(i); if (child.getNodeName().equals(attrName)) { return child.getNodeValue(); return null; |
int | getElementIntAttr(Node element, String attrName) get Element Int Attr String attrValue = getElementAttr(element, attrName); if (attrValue != null) { return Integer.parseInt(attrValue); return 0; |
int | getElementIntAttr(Node element, String attrName) get Element Int Attr String attrValue = getElementAttr(element, attrName); if (attrValue != null) { return Integer.parseInt(attrValue); return 0; |
Object | getEnumAttribute(Node archiveNode, String attrName, Object[] values, Object defaultValue) Retrieve an attribute which value must match one of the given enums using a case-insensitive name match. Node attr = archiveNode.getAttributes().getNamedItem(attrName); if (attr != null) { String found = attr.getNodeValue(); for (Object value : values) { if (value.toString().equalsIgnoreCase(found)) { return value; return defaultValue; |