Here you can find the source of getDirectChildNamedElements( Element parent, String name)
Parameter | Description |
---|---|
parent | the parent whose direct children will be processed |
name | the child tag name to match |
public static ArrayList<Element> getDirectChildNamedElements( Element parent, String name)
//package com.java2s; import java.util.ArrayList; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/*from w ww . ja v a 2 s. co m*/ * Returns a collection of direct child Elements that match the specified tag name * @param parent the parent whose direct children will be processed * @param name the child tag name to match * @return a collection of matching Elements */ public static ArrayList<Element> getDirectChildNamedElements( Element parent, String name) { ArrayList<Element> result = new ArrayList<Element>(); for (Node child = parent.getFirstChild(); child != null; child = child .getNextSibling()) { if (child instanceof Element && name.equals(child.getNodeName())) { result.add((Element) child); } } return result; } }