Java XML First Child Element getFirstChildElement(Element parent)

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

Description

Get the indexed Element.

License

LGPL

Declaration


public static Element getFirstChildElement(Element parent) 

Method Source Code

//package com.java2s;
// Metawidget (licensed under LGPL)

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    /**/*w  ww  .j a v a 2s  . c om*/
     * Get the indexed Element.
     * <p>
     * Similar to <code>Element.getChildNodes.item</code>, but ignores any Nodes (such as
     * indentation TextNodes).
     */

    public static Element getFirstChildElement(Element parent) {

        Node node = parent.getFirstChild();

        while (node != null && !(node instanceof Element)) {

            node = node.getNextSibling();
        }

        return (Element) node;
    }
}

Related

  1. getFirstChildElement(Element element)
  2. getFirstChildElement(Element element, String namespaceURI, String tagName)
  3. getFirstChildElement(Element elm, String name)
  4. getFirstChildElement(Element elm, String name)
  5. getFirstChildElement(Element elm, String name)
  6. getFirstChildElement(Element parent)
  7. getFirstChildElement(Element parent)
  8. getFirstChildElement(Element parent, String childName)
  9. getFirstChildElement(Element parent, String nsUri, String localPart)