List of utility methods to do XML Attribute Get
String | getAttributeValueAsString(Node node) Gets the attribute value as string. if (node != null) { return node.getNodeValue(); return null; |
boolean | getAttributeValueBoolean(Node node, String attrName) Returns boolean value of the named attribute of the node. String value = getAttributeValue(node, attrName); return "true".equalsIgnoreCase(value) || "1".equals(value); |
String | getAttributeValueByName(NamedNodeMap nnm, String name) Searches throgh the passed NamedNodeMap for an attribute and returns it if it is found. if (nnm == null) return null; for (int i = 0; i < nnm.getLength(); i++) { Attr attr = (Attr) nnm.item(i); if (attr.getName().equalsIgnoreCase(name)) { return attr.getValue(); return null; |
String | getAttributeValueByName(NamedNodeMap nnm, String name) Searches throgh the passed NamedNodeMap for an attribute and returns it if it is found. for (int i = 0; i < nnm.getLength(); i++) { Attr attr = (Attr) nnm.item(i); if (attr.getName().equalsIgnoreCase(name)) { return attr.getValue(); return null; |
String | getAttributeValueByName(Node node, String name) Returns the attribute value for the passed name in the passed node. return getAttributeValueByName(node.getAttributes(), name);
|
String | getAttributeValueByName(Node node, String name) Returns the attribute value for the passed name in the passed node. return getAttributeValueByName(node.getAttributes(), name);
|
String | getAttributeValueEmptyNull(Element e, String attributeName) This function is much like getAttribute, but returns null, not "", for a nonexistent attribute. Attr node = e.getAttributeNode(attributeName); if (node == null) { return null; return node.getValue(); |
String | getAttributeValueIgnoreCase(Element element, String attributeName) Gets the value of DOM attribute of element with the given name It returns the first attribute value that matches the name, regardless the case.
Attr a = getAttributeIgnoreCase(element, attributeName); if (a != null) { a.getValue(); return null; |
String | getAttributeValueNS(@Nonnull final Element aElement, @Nullable final String sNamespaceURI, @Nonnull final String sAttrName, @Nullable final String sDefault) The latest version of XercesJ 2.9 returns an empty string for non existing attributes. final Attr aAttr = aElement.getAttributeNodeNS(sNamespaceURI, sAttrName); return aAttr == null ? sDefault : aAttr.getValue(); |
String | getAttributeValueNS(Element element, String namespace, String attrName) Get attribute value. String attrValue = null; Attr attr = null; if ((attr = element.getAttributeNodeNS(namespace, attrName)) != null) { attrValue = attr.getValue().trim(); return attrValue; |