Java XML Child Get getChildElements(Element parentElement)

Here you can find the source of getChildElements(Element parentElement)

Description

get Child Elements

License

LGPL

Declaration

public static List<Element> getChildElements(Element parentElement) 

Method Source Code

//package com.java2s;
/*//from w w w .j a  v a 2s.  c o  m
 * JFox - The most lightweight Java EE Application Server!
 * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
 *
 * JFox is licenced and re-distributable under GNU LGPL.
 */

import java.util.ArrayList;

import java.util.List;

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

public class Main {
    public static List<Element> getChildElements(Element parentElement) {
        NodeList nodeList = parentElement.getChildNodes();
        List<Element> childElements = new ArrayList<Element>(nodeList.getLength());
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node childNode = nodeList.item(0);
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                childElements.add((Element) childNode);
            }
        }
        return childElements;
    }
}

Related

  1. getChildElements(Element parent)
  2. getChildElements(Element parent)
  3. getChildElements(Element parent)
  4. getChildElements(Element parent)
  5. getChildElements(Element parentElement)
  6. getChildElements(Element parentElement, String childElementTagName)
  7. getChildElements(Element parentNode)
  8. getChildElements(Element root, String name, boolean mandatory)
  9. getChildElements(final Element elem)