Java XML NodeList asList(NodeList nodeList)

Here you can find the source of asList(NodeList nodeList)

Description

Returns a List view of the nodes in the given NodeList collection.

License

Apache License

Parameter

Parameter Description
nodeList An ordered collection of DOM nodes.

Return

A List containing the original sequence of Node objects.

Declaration

public static List<Node> asList(NodeList nodeList) 

Method Source Code

//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;
    }
}

Related

  1. addAll(final Node dst, final NodeList src)
  2. asList(final NodeList scripts)
  3. canonizeNodeList(NodeList nodelist)
  4. combine(final NodeList... nls)
  5. combineNodeLists(NodeList successfulReportList, NodeList failedAssertList)
  6. containsElementByValue(NodeList elements, String value)