List of utility methods to do XML Has Child
boolean | hasChildren(Element element) has Children return !getChildren(element).isEmpty();
|
boolean | hasChildren(Element element) Check if an element has some children. if (element != null) { return element.hasChildNodes(); return false; |
boolean | hasChildren(Element element, String childName) has Children NodeList ndLs = element.getElementsByTagName(childName); if (ndLs == null) return false; if (ndLs.getLength() > 0) return true; return false; |
boolean | hasChildren(final Element el) See if this node has any children NodeList children = el.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node curnode = children.item(i); short ntype = curnode.getNodeType(); if ((ntype != Node.TEXT_NODE) && (ntype != Node.CDATA_SECTION_NODE) && (ntype != Node.COMMENT_NODE)) { return true; return false; |
boolean | hasChildren(final Node node) has Children return node == null ? false : node.hasChildNodes();
|
boolean | hasElementChild(Node node) Checks if a node has a child of ELEMENT type. NodeList nl = node.getChildNodes(); Node child = null; int length = nl.getLength(); for (int i = 0; i < length; i++) { child = nl.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { return true; return false; |
boolean | hasElementChild(Node node) Checks if a node has a child of ELEMENT type. NodeList nl = node.getChildNodes(); Node child = null; int length = nl.getLength(); for (int i = 0; i < length; i++) { child = nl.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { return true; return false; |
boolean | hasElementChildren(Element element) just the same as hasNonWhitespaceChildren, but seen from a different perspective ;) return hasNonWhitespaceChildren(element);
|
boolean | hasElementChildren(Element elemNode) Returns true if the input element has element children. NodeList nl = elemNode.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node cand = nl.item(i); if (cand.getNodeType() == Node.ELEMENT_NODE) { return true; return false; ... |
boolean | hasElementChildren(Element elemNode) Returns true if the input element has element children. NodeList nl = elemNode.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node cand = nl.item(i); if (cand.getNodeType() == Node.ELEMENT_NODE) { return true; return false; ... |