Java XML First Child Element getFirstChildElement(Element element)

Here you can find the source of getFirstChildElement(Element element)

Description

Returns the first child element, or null if none exists.

License

Open Source License

Parameter

Parameter Description
element a parameter

Return

Element

Declaration

public static Element getFirstChildElement(Element element) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    /**//from  ww w.jav a 2  s  . c om
     * Returns the first child element, or null if none exists.
     * @param element
     * @return Element
     */
    public static Element getFirstChildElement(Element element) {
        for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
            if (node instanceof Element) {
                return (Element) node;
            }
        }

        return null;
    }
}

Related

  1. getFirstChildElement(Element elem)
  2. getFirstChildElement(Element element)
  3. getFirstChildElement(Element element)
  4. getFirstChildElement(Element element)
  5. getFirstChildElement(Element element)
  6. getFirstChildElement(Element element, String namespaceURI, String tagName)
  7. getFirstChildElement(Element elm, String name)
  8. getFirstChildElement(Element elm, String name)
  9. getFirstChildElement(Element elm, String name)