Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Gets the sub nodes. * * @param dataNode * the data node * @return the sub nodes */ public static List<Node> getSubNodes(Node dataNode) { List<Node> returnList = new ArrayList<Node>(); NodeList list = dataNode.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); returnList.add(node); } return returnList; } public static List<Node> getChildNodes(Node dataNode) { List<Node> returnList = new ArrayList<Node>(); NodeList list = dataNode.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node.getNodeType() != Node.TEXT_NODE) { returnList.add(node); } } return returnList; } }