Java XML First Child Element getFirstChildElementNode(Node node)

Here you can find the source of getFirstChildElementNode(Node node)

Description

get First Child Element Node

License

Open Source License

Declaration

public static Node getFirstChildElementNode(Node node) 

Method Source Code

//package com.java2s;
/*/*ww  w . j  a  va 2 s.c  o m*/
 * The following methods come from a library written by Tom Fennelly.
 * Here was the header of the licence.
 */

import org.w3c.dom.*;

public class Main {
    public static Node getFirstChildElementNode(Node node) {
        if (node == null)
            return (null);

        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if (Node.ELEMENT_NODE == child.getNodeType())
                return (child);
        }

        return (null);
    }
}

Related

  1. getFirstChildElementByName(Node node, String name)
  2. getFirstChildElementByTagName(Element element, String name)
  3. getFirstChildElementByTagName(Node element, String tagName)
  4. getFirstChildElementCaseInsensitive(Element root, String elementName)
  5. getFirstChildElementInternal(final Node node, final boolean useNamespaces, final String namespaceURI, final String localName)
  6. getFirstChildElementNS(Element elm, String tns, String localName)
  7. getFirstChildElementNS(Node parent, String uri)
  8. getFirstChildElementNS(Node parent, String[][] elemNames)
  9. getFirstChildElementOfName(@Nonnull final Node aStartNode, @Nullable final String sName)