Here you can find the source of getDirectChildElements(Element parent)
Parameter | Description |
---|---|
parent | the parent whose direct children will be processed |
public static ArrayList<Element> getDirectChildElements(Element parent)
//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 a2s . c om*/ * Returns a collection of direct child Elements * @param parent the parent whose direct children will be processed * @return a collection of all child Elements */ public static ArrayList<Element> getDirectChildElements(Element parent) { ArrayList<Element> result = new ArrayList<Element>(); for (Node child = parent.getFirstChild(); child != null; child = child .getNextSibling()) { if (child instanceof Element) { result.add((Element) child); } } return result; } }