Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static List<Element> getSubChildElementList(Element ele, String tagname) { int p0 = tagname.indexOf(':'); if (p0 >= 0) tagname = tagname.substring(p0 + 1); return getSubChildElementList(ele, new String[] { tagname }); } public static List<Element> getSubChildElementList(Element ele, String[] tagnames) { if (ele == null) { return null; } List<Element> v = new ArrayList<Element>(); // boolean isall = false; NodeList tmpnl = ele.getChildNodes(); Node tmpn = null; int k; for (k = 0; k < tmpnl.getLength(); k++) { tmpn = tmpnl.item(k); if (tmpn.getNodeType() != Node.ELEMENT_NODE) { continue; } Element eee = (Element) tmpn; String noden = eee.getNodeName(); int p = noden.indexOf(':'); if (p >= 0) noden = noden.substring(p + 1); for (String tagname : tagnames) { if (tagname.equals(noden) || tagname.equals("*")) { v.add(eee); break; } } } return v; } }