Java tutorial
//package com.java2s; //License from project: Apache License import java.util.LinkedList; import java.util.List; import org.w3c.dom.Node; public class Main { public static List childNodeList(Node node, String childNodeName) { if (node == null) return null; List children = new LinkedList(); Node childNode = node.getFirstChild(); if (childNode != null) { do { if (childNode.getNodeType() == Node.ELEMENT_NODE && (childNodeName == null || childNodeName.equals(childNode.getNodeName()))) { children.add(childNode); } } while ((childNode = childNode.getNextSibling()) != null); } return children; } public static List childNodeList(Node node) { if (node == null) return null; List children = new LinkedList(); Node childNode = node.getFirstChild(); if (childNode != null) { do { if (childNode.getNodeType() == Node.ELEMENT_NODE) { children.add(childNode); } } while ((childNode = childNode.getNextSibling()) != null); } return children; } }