Java XML First Child Element getFirstChildElement(Element element)

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

Description

Gets the first child element of an element

License

Apache License

Parameter

Parameter Description
element the parent

Return

the first child element or null if there isn't one

Declaration

public static Element getFirstChildElement(Element element) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**/*from   ww  w  .  ja  v a  2 s  .  c  om*/
     * Gets the first child element of an element
     *
     * @param element the parent
     * @return the first child element or null if there isn't one
     */
    public static Element getFirstChildElement(Element element) {
        Node child = element.getFirstChild();
        while (child != null && child.getNodeType() != Node.ELEMENT_NODE)
            child = child.getNextSibling();

        return (Element) child;
    }
}

Related

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