Java XML First Child Element getFirstChild(Element element)

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

Description

get First Child

License

Open Source License

Declaration

public static Element getFirstChild(Element element) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Element getFirstChild(Element element) {

        NodeList nodelist = element.getChildNodes();
        for (int i = 0; i < nodelist.getLength(); i++) {
            Node node = nodelist.item(i);
            if (node instanceof Element)
                return (Element) node;
        }/*w w  w .ja  v a  2s.c  o m*/
        return null;
    }
}

Related

  1. getDirectChildNodes(final Node parent, final String... nodeNames)
  2. getDirectChildNodes(Node node, String name)
  3. getFirstChild(Element e)
  4. getFirstChild(Element e, String nsUri, String local)
  5. getFirstChild(Element elem, String childTag)
  6. getFirstChild(Element element)
  7. getFirstChild(Element element)
  8. getFirstChild(Element element)
  9. getFirstChild(Element element, String child)