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(Node node)
Get the first child Element of the supplied node.
NodeList children = node.getChildNodes();
int childCount = children.getLength();
for (int i = 0; i < childCount; i++) {
    Node child = children.item(i);
    if (child != null && child.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) child;
return null;
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)
Returns the first child element of the specified node, or null if there is no such element.
Node child = node.getFirstChild();
while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
    child = child.getNextSibling();
return (Element) child;
ElementgetFirstChildElement(Node node)
Returns the first child Element of a given Node.
Node child = node.getFirstChild();
while ((child != null) && (child.getNodeType() != Node.ELEMENT_NODE)) {
    child = child.getNextSibling();
return (Element) child;
ElementgetFirstChildElement(Node node)
Returns the First child element or null if none found
if (node == null) {
    return null;
Node child = node.getFirstChild();
if (child instanceof Element) {
    return (Element) child;
} else {
    return getNextElement(child);
...
NodegetFirstChildElement(Node node)
Get a first XML element of a given node.
if (node == null)
    return null;
Node child = node.getFirstChild();
if (child == null)
    return null;
if (child.getNodeType() == Node.ELEMENT_NODE)
    return child;
while (child != null) {
...
ElementgetFirstChildElement(Node node)
Get the first child node that is an element node.
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
    if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
        return (Element) children.item(i);
return null;
ElementgetFirstChildElement(Node node)
get First Child Element
return getNthChildElement(node, 0);
ElementgetFirstChildElement(Node node, String tag)
Return the first child element under node that has given given tag name.
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
    Node temp = list.item(i);
    if (temp.getNodeType() != Node.ELEMENT_NODE)
        continue;
    Element tempElement = (Element) temp;
    if (tempElement.getTagName().equals(tag))
        return tempElement;
...
ElementgetFirstChildElement(Node parent)
Finds and returns the first child element node.
Node child = parent.getFirstChild();
while (child != null) {
    if (child.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) child;
    child = child.getNextSibling();
return null;
...