Java XML First Child Element getFirstElementChild(Element parent)

Here you can find the source of getFirstElementChild(Element parent)

Description

Finds the first element child, or null if not found.

License

Open Source License

Declaration

static Element getFirstElementChild(Element parent) 

Method Source Code


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

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

public class Main {
    /** Finds the first element child, or null if not found. */
    static Element getFirstElementChild(Element parent) {
        for (Node n = parent.getFirstChild(); n != null; n = n.getNextSibling()) {
            if (n.getNodeType() == Node.ELEMENT_NODE)
                return (Element) n;
        }/* w  ww .  j av  a2 s .c o m*/
        return null;
    }
}

Related

  1. getFirstElement(Element element, String childName)
  2. getFirstElementChild(Element aElement)
  3. getFirstElementChild(Element element)
  4. getFirstElementChild(Element elemNode)
  5. getFirstElementChild(Element elemNode)
  6. GetFirstElementChild(Element tag)
  7. getFirstElementChild(final Element element, final String namespace, final String localname)
  8. getFirstElementChild(final Node node)
  9. getFirstElementChild(final Node node)