Here you can find the source of toList(final NodeList nodes)
public static <T> List<T> toList(final NodeList nodes)
//package com.java2s; //License from project: Apache License import java.util.*; import org.w3c.dom.*; public class Main { /** Convert DOM NodeList to List. */ public static <T> List<T> toList(final NodeList nodes) { final List<T> res = new ArrayList<>(nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { res.add((T) nodes.item(i));// w w w . j a v a2 s . c om } return res; } }