Java XML First Child Element getFirstChild(Element e)

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

Description

get First Child

License

Open Source License

Declaration

public static Element getFirstChild(Element e) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Element getFirstChild(Element e) {
        if (e == null)
            return null;
        Node n = e.getFirstChild();
        while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
            n = n.getNextSibling();//from w  w w  .j  ava 2 s  .  c  o m
        return (Element) n;
    }

    public static Element getNextSibling(Element e) {
        Node n = e.getNextSibling();
        while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
            n = n.getNextSibling();
        return (Element) n;
    }
}

Related

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