Java Utililty Methods XML First Child Element

List of utility methods to do XML First Child Element

Description

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

Method

ElementgetFirstChildElement(Element parentElem)
get First Child Element
if (parentElem == null) {
    return null;
Node child = parentElem.getFirstChild();
while (child != null) {
    if (child.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) child;
    child = child.getNextSibling();
return null;
ElementgetFirstChildElement(Element root)
getFirstChildElement purpose.
Node child = root.getFirstChild();
while (child != null) {
    if (child.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) child;
    child = child.getNextSibling();
return null;
...
ElementgetFirstChildElement(final Node node)
Gets the first child Element of the specified Node , if any.
return getFirstChildElementInternal(node, false, null, null);
ElementgetFirstChildElement(final Node parent, final String elemName)
get First Child Element
for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
    final short nodeType = child.getNodeType();
    if (nodeType == Node.ELEMENT_NODE) {
        final String nodeName = child.getNodeName();
        if (nodeName.equals(elemName)) {
            return (Element) child;
return null;
ElementgetFirstChildElement(Node n)
Gets the first child Element of the node, skipping any Text nodes such as whitespace.
Node child = n.getFirstChild();
while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
    child = child.getNextSibling();
if (child != null) {
    return (Element) child;
} else {
    return null;
...
ElementgetFirstChildElement(Node n, String ns, String localName)
Gets the first child Element of the node of the given name, skipping any Text nodes such as whitespace.
Element e = getFirstChildElement(n);
while (e != null && !isElementNamed(e, ns, localName))
    e = getNextSiblingElement(e);
return e;
ElementgetFirstChildElement(Node node)
Gets the first child org.w3c.dom.Element of the given Node.
NodeList children = null;
int numChildren = 0;
if (node == null || (children = node.getChildNodes()) == null
        || (numChildren = node.getChildNodes().getLength()) == 0) {
    return null;
Element result = null;
for (int i = 0; i < numChildren && result == null; i++) {
...
ElementgetFirstChildElement(Node node)
get First Child Element
Node child = node.getFirstChild();
while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
    child = child.getNextSibling();
return (Element) child;
ElementgetFirstChildElement(Node node)
Gets the first child element of a node.
node = node.getFirstChild();
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
    node = node.getNextSibling();
return (Element) node;
NodegetFirstChildElement(Node node)
get First Child Element
Node firstChildElement = null;
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
    if (child.getNodeType() != Node.TEXT_NODE) {
        firstChildElement = child;
        break;
return firstChildElement;
...