Java XML First Child Element getFirstElementChild(Node root)

Here you can find the source of getFirstElementChild(Node root)

Description

get First Element Child

License

Open Source License

Parameter

Parameter Description
root a parameter

Declaration

public static Element getFirstElementChild(Node root) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    /**//from ww w  . j  av a  2  s  .c  om
     * @param root
     * @return
     */
    public static Element getFirstElementChild(Node root) {
        Node node = root.getFirstChild();
        while (node != null) {
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                return (Element) node;
            }
            node = node.getNextSibling();
        }
        return null;
    }
}

Related

  1. getFirstElementChild(Element parent)
  2. GetFirstElementChild(Element tag)
  3. getFirstElementChild(final Element element, final String namespace, final String localname)
  4. getFirstElementChild(final Node node)
  5. getFirstElementChild(final Node node)
  6. getFirstElementContent(Element element, String childName)
  7. getFirstElemText(Element parent, String childName)
  8. getFirstLevelChildElementByTagName(Element parent, String elementName)
  9. getFirstLevelChildElementByTagName(Element parent, String elementName)