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

HashtablegetChildHash(Element elem, String elementName, String attrName)
get Child Hash
if (elem == null)
    return null;
NodeList nl = elem.getChildNodes();
if (nl == null)
    return null;
Hashtable<String, Element> retlist = new Hashtable<String, Element>(100);
for (int n = 0; n < nl.getLength(); n++) {
    Node child = nl.item(n);
...
ElementgetLastVisibleChildElement(Node parent, Hashtable hiddenNodes)
Finds and returns the last visible child element node.
Node child = parent.getLastChild();
while (child != null) {
    if (child.getNodeType() == Node.ELEMENT_NODE && !isHidden(child, hiddenNodes)) {
        return (Element) child;
    child = child.getPreviousSibling();
return null;
...
booleanhasActivityChildNode(Node node)
Checks whether the node has a child node that represents a BPEL activity.
boolean foundNonTextChild = false;
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
    if (!(child instanceof Text)) {
        if (BPEL_ACTIVITIES.contains(child.getNodeName())) {
            foundNonTextChild = true;
return foundNonTextChild;
booleanhasAnyChildElement(final Element e)
has Any Child Element
for (Node child = e.getFirstChild(); child != null; child = child.getNextSibling()) {
    if (child instanceof Element) {
        return true;
return false;
booleanhasChild(Element element, String child)
Determine whether a single child is available of a particular type.
NodeList nodes = element.getChildNodes();
Element ret = null;
for (int i = 0; i < nodes.getLength(); i++) {
    Node childNode = nodes.item(i);
    if (childNode.getNodeName().equals(child) && childNode.getNodeType() == Node.ELEMENT_NODE) {
        if (ret != null) {
            throw new Exception("Child element '" + child + "' present multiple times");
        } else {
...
booleanhasChild(Element node, String name)
This method checks whether the given element node has a child element with the given name.
List<Element> children = getDirectChildElementsByTag(node, DOM_WILDCARD);
for (Element e : children) {
    if (e.getNodeName().equals(name)) {
        return true;
return false;
booleanhasChild(Element parent, String nodeName)
has Child
NodeList childNodes = parent.getChildNodes();
int length = childNodes.getLength();
for (int i = 0; i < length; i++)
    if (childNodes.item(i).getNodeName().equals(nodeName))
        return true;
return false;
booleanhasChild(Element root, String childName)
has Child
return (root.getElementsByTagName(childName).getLength() > 0);
booleanhasChild(Element start, String name)
__UNDOCUMENTED__
NodeList nl = start.getChildNodes();
int len = nl.getLength();
Node n = null;
for (int i = 0; i < len; i++) {
    n = nl.item(i);
    if (n.getNodeName().equals(name)) {
        return true;
return false;
booleanhasChild(Node n)
has Child
NodeList nl = n.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
    n = nl.item(i);
    if (n.getNodeType() == 1)
        return true;
return false;