List of utility methods to do XML Attribute Exist
boolean | hasAttribute(Node node, String attributeName, String className) Checks the presence of an attribute value in attributes that contain whitespace-separated lists of values. String attr = readAttribute(node, attributeName); for (String c : attr.split("\\s+")) if (c.equalsIgnoreCase(className)) return true; return false; |
boolean | hasAttributeValue(final Element element, final String attributeName) has Attribute Value final String attributeValue = element.getAttribute(attributeName); return attributeValue != null && !attributeValue.isEmpty(); |
boolean | hasAttributeValue(Node node, String attributeName, String attributeValue) has Attribute Value if (node == null || attributeName == null) { return false; String value = getAttributeValue(node, attributeName); if (value == null) { return (attributeValue == null) ? true : false; if (value.equals(attributeValue)) { ... |
boolean | hasAttributeValue(String expected, String attribute, Element element) has Attribute Value Node node = getAttributeOrNull(attribute, element);
return node != null && expected.equals(node.getTextContent());
|
boolean | hasElementWithAttr(Element modsroot, String nodename, String attrname, String attrvalue) has Element With Attr boolean found = false; NodeList list = modsroot.getElementsByTagName(nodename); for (int i = 0; i < list.getLength(); i++) { Node node = (Node) list.item(i); NamedNodeMap attrs = node.getAttributes(); Attr attr = (Attr) attrs.getNamedItem(attrname); if (attr != null) { if (attr.getValue().equals(attrvalue)) { ... |
boolean | isAttribute(Node node) is Attribute return node.getNodeType() == Node.ATTRIBUTE_NODE;
|
boolean | isAttribute(Object obj) Checks if the class field is XML attribute. boolean ret = false; if (null != obj) { Class<?> clazz = obj.getClass(); Annotation annotation = clazz.getAnnotation(XmlAnyAttribute.class); if (null != annotation) { ret = true; return ret; |
boolean | isAttributePresent(XMLStreamReader reader, String name) Test if an attribute is explicitly set return reader.getAttributeValue(null, name) != null;
|