List of utility methods to do XML Attribute Get
String | getAttributeValue(Node sNode, String attribName) Utility method to fetch the attribute value from the given element node String value = null; NamedNodeMap attrs = sNode.getAttributes(); if (attrs != null) { Node attr = attrs.getNamedItem(attribName); if (attr != null) { value = attr.getNodeValue(); return value; |
String | getAttributeValue(NodeList elements, String attributeName) Return the value of the named attribute from the first Node in the NodeList or null if the NodeList is empty or the attribute is not present. String result = null; if (elements != null && elements.getLength() > 0) { Node item = elements.item(0); NamedNodeMap attributes = item.getAttributes(); if (attributes != null) { Node attr = attributes.getNamedItem(attributeName); if (attr != null) { result = attr.getNodeValue(); ... |
String | getAttributeValue(StartElement element, String namespaceURI, String localPart) get Attribute Value QName name = new QName(namespaceURI == null ? XMLConstants.NULL_NS_URI : namespaceURI, localPart); Attribute attribute = element.getAttributeByName(name); return attribute == null ? null : attribute.getValue(); |
String | getAttributeValue(StartElement startElement, String attributeName) Gets the value of a given attribute String value = null; Attribute idAttr = startElement.getAttributeByName(new QName(attributeName)); if (idAttr != null) { value = idAttr.getValue(); return value; |
String | getAttributeValue(String attributeName, Node xmlNode) get Attribute Value if (xmlNode == null) return null; if (xmlNode.getAttributes() == null) return null; if (xmlNode.getAttributes().getLength() == 0) return null; Node n = xmlNode.getAttributes().getNamedItem(attributeName); if (n == null) ... |
Boolean | getAttributeValueAsBoolean(Attr attribute) Parses the attribute's value. if (attribute == null) { return null; String valueStr = attribute.getValue(); if (valueStr.equals("0") || valueStr.equals("false")) { return Boolean.FALSE; } else if (valueStr.equals("1") || valueStr.equals("true")) { return Boolean.TRUE; ... |
boolean | getAttributeValueAsBoolean(Element el, String attrName) Get the boolean value from the given attribute. return getAttributeValueAsBoolean(el, new QName(attrName)); |
Double | getAttributeValueAsDouble(Node node, String attributeName) get Attribute Value As Double return Double.parseDouble(node.getAttributes().getNamedItem(attributeName).getTextContent());
|
Integer | getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue) get Attribute Value As Integer final Node attributeNode = node.getAttributes().getNamedItem(attributeName); return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : defaultValue; |
long | getAttributeValueAsLong(final Element el, final String attrName, final long defaultVal) get Attribute Value As Long return getAttributeValueAsLong(el, new QName(attrName), defaultVal); |