Java XML NodeList toList(final NodeList nodeList)

Here you can find the source of toList(final NodeList nodeList)

Description

Turns a NodeList into a list.

License

Open Source License

Parameter

Parameter Description
nodeList the node list

Return

list list

Declaration

public static List<Node> toList(final NodeList nodeList) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*  w w w  .  ja  v a  2  s  . c om*/
     * Turns a NodeList into a list.
     *
     * @param nodeList the node list
     * @return list list
     */
    public static List<Node> toList(final NodeList nodeList) {
        final List<Node> list = new ArrayList<Node>(nodeList.getLength());

        for (int nlIndex = 0; nlIndex < nodeList.getLength(); nlIndex++) {
            list.add(nodeList.item(nlIndex));
        }

        return list;
    }
}

Related

  1. stream(NodeList nodes)
  2. toArrayList(NodeList nl)
  3. toElementArray(NodeList list)
  4. toElementIterable(NodeList nodeList)
  5. toList(final NodeList aList)
  6. toList(final NodeList nodes)
  7. toList(NodeList nodes)
  8. toNodeArray(NodeList list)
  9. toNodeArray(NodeList list)