Here you can find the source of toElementList(NodeList nodeList)
Parameter | Description |
---|---|
nodeList | the node list |
public static List<Element> toElementList(NodeList nodeList)
//package com.java2s; 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 w w . j a v a2s . c o m * Gets all the elements out of a {@link NodeList}. * @param nodeList the node list * @return the elements */ public static List<Element> toElementList(NodeList nodeList) { List<Element> elements = new ArrayList<Element>(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { elements.add((Element) node); } } return elements; } }