Java tutorial
//package com.java2s; 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> getChildNodes(Element parent) { NodeList list = parent.getChildNodes(); List<Element> children = new ArrayList<Element>(list.getLength()); for (int i = 0; i < list.getLength(); i++) { Node child = list.item(i); if (child.getNodeType() == 1) children.add((Element) child); } return children; } public static List<Element> getChildNodes(Element parent, String name) { NodeList list = parent.getElementsByTagName(name); List<Element> children = new ArrayList<Element>(list.getLength()); for (int i = 0; i < list.getLength(); i++) { Node child = list.item(i); if (child.getNodeType() == 1) children.add((Element) child); } return children; } }