Here you can find the source of asList(NodeList nodeList)
Parameter | Description |
---|---|
nodeList | An ordered collection of DOM nodes. |
public static List<Node> asList(NodeList nodeList)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**//w w w . j a v a 2 s . c o m * Returns a List view of the nodes in the given NodeList collection. * * @param nodeList * An ordered collection of DOM nodes. * @return A List containing the original sequence of Node objects. */ public static List<Node> asList(NodeList nodeList) { List<Node> nodes = new ArrayList<>(); for (int i = 0; i < nodeList.getLength(); i++) { nodes.add(nodeList.item(i)); } return nodes; } }