Java Utililty Methods XML Element Check

List of utility methods to do XML Element Check

Description

The list of methods to do XML Element Check are organized into topic(s).

Method

booleanis(final Element e, final String tag)
is
return e.getTagName().equalsIgnoreCase(tag);
booleanisAncestor(Element candAnc, Node cand)
Check, if a given DOM element is an ancestor of a given node.
Node currPar = cand.getParentNode();
while (currPar != null) {
    if (candAnc == currPar)
        return true;
    currPar = currPar.getParentNode();
return false;
booleanisAppearanceTag(Element e)
is Appearance Tag
if (e.getTagName().matches("H[1-9]")) {
    return true;
if (e.getTagName().equals("FONT") && !e.getAttribute("COLOR").equals("")) {
    return true;
if (e.getTagName().matches("[B|I|STRONG]")) {
    return true;
...
booleanisAsyncEventQueue(Element element)
is Async Event Queue
return ASYNC_EVENT_QUEUE_ELEMENT_NAME.equals(element.getLocalName());
booleanisComputedGoal(final Element element)
Check if an element describes a computed goal or not.
return "computedGoal".equals(element.getNodeName());
booleanisElement(XMLStreamReader xmlRdr, int eventType, String tagName)
is Element
int event = xmlRdr.getEventType();
if (event == eventType) {
    String locName = xmlRdr.getLocalName();
    if (locName.equals(tagName))
        return true;
return false;
booleanisElementExistsByTagName(final Element element, final String tagName)
Checks if is element exists by tag name.
if (element == null || tagName == null || tagName.isEmpty()) {
    return false;
final NodeList res = element.getChildNodes();
for (int i = 0; i < res.getLength(); i++) {
    final Node node = res.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        final Element elem = (Element) node;
...
booleanisElementNamed(Element e, String ns, String localName)
Shortcut for checking a DOM element node's namespace and local name
return (e != null && safeCompare(ns, e.getNamespaceURI()) && safeCompare(localName, e.getLocalName()));
booleanisEmpty(final Element el)
See if this node is empty
return !hasChildren(el) && !hasContent(el);
booleanisEmptyElement(Element el)
Check that an element is empty, i.e., it contains no non-whitespace text or elements as children.
NodeList nl = el.getChildNodes();
int len = nl.getLength();
for (int i = 0; i < len; ++i) {
    switch (nl.item(i).getNodeType()) {
    case Node.CDATA_SECTION_NODE:
    case Node.TEXT_NODE:
        String s = nl.item(i).getNodeValue();
        if (s != null && s.trim().length() > 0) {
...