Here you can find the source of getChildElements(Element element)
Parameter | Description |
---|---|
element | a parameter |
tag | a parameter |
public static List<Element> getChildElements(Element element)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**//from w ww . j av a 2 s . com * get single element by tag name * @param element * @param tag * @return */ public static List<Element> getChildElements(Element element) { List<Element> elems = new ArrayList<Element>(); NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Element) { Element e = (Element) node; elems.add(e); } } return elems; } }