Here you can find the source of getChildElements(Node node)
public static List getChildElements(Node node)
//package com.java2s; /**/* ww w . j a va2 s .c o m*/ * This file is part of SIMPL4(http://simpl4.org). * * Copyright [2014] [Manfred Sattler] <manfred@ms123.org> * * SIMPL4 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SIMPL4 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SIMPL4. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Returns a list of all child Elements, */ public static List getChildElements(Node node) { return getChildElements(node, null); } /** * Returns a list of child Elements of specified name. */ public static List getChildElements(Node node, String nodeName) { NodeList childs = node.getChildNodes(); return filterNodeListElements(childs, nodeName); } /** * Filter node list for all Element nodes. */ public static List filterNodeListElements(NodeList nodeList) { return filterNodeListElements(nodeList, null); } /** * Filter node list for Element nodes of specified name. */ public static List<Node> filterNodeListElements(NodeList nodeList, String nodeName) { List<Node> nodes = new ArrayList<Node>(); for (int k = 0; k < nodeList.getLength(); k++) { Node node = nodeList.item(k); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } if (nodeName != null && (node.getNodeName().equals(nodeName) == false)) { continue; } nodes.add(node); } return nodes; } }