Java XML NodeList toList(final NodeList nodes)

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

Description

Convert DOM NodeList to List.

License

Apache License

Declaration

public static <T> List<T> toList(final NodeList nodes) 

Method Source Code

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

Related

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