Java Utililty Methods XML Has Child

List of utility methods to do XML Has Child

Description

The list of methods to do XML Has Child are organized into topic(s).

Method

booleanhasChildren(Element element)
has Children
return !getChildren(element).isEmpty();
booleanhasChildren(Element element)
Check if an element has some children.
if (element != null) {
    return element.hasChildNodes();
return false;
booleanhasChildren(Element element, String childName)
has Children
NodeList ndLs = element.getElementsByTagName(childName);
if (ndLs == null)
    return false;
if (ndLs.getLength() > 0)
    return true;
return false;
booleanhasChildren(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;
booleanhasChildren(final Node node)
has Children
return node == null ? false : node.hasChildNodes();
booleanhasElementChild(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;
booleanhasElementChild(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;
booleanhasElementChildren(Element element)
just the same as hasNonWhitespaceChildren, but seen from a different perspective ;)
return hasNonWhitespaceChildren(element);
booleanhasElementChildren(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;
...
booleanhasElementChildren(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;
...