Java Utililty Methods XML NodeList

List of utility methods to do XML NodeList

Description

The list of methods to do XML NodeList are organized into topic(s).

Method

Streamstream(NodeList nodes)
stream
return IntStream.range(0, nodes.getLength()).mapToObj(nodes::item);
ListtoArrayList(NodeList nl)
to Array List
List<Node> res = new ArrayList<Node>();
for (int i = 0; i < nl.getLength(); i++) {
    res.add(nl.item(i));
return res;
Element[]toElementArray(NodeList list)
to Element Array
Node[] nodes = toNodeArray(list);
List<Element> retVal = new ArrayList<Element>();
for (Node n : nodes) {
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        retVal.add((Element) n);
return retVal.toArray(new Element[] {});
...
IterabletoElementIterable(NodeList nodeList)
Converts a NodeList to an Iterable of Elements.
List<Element> elements = new ArrayList<>(nodeList.getLength());
for (int i = 0; i < nodeList.getLength(); i++) {
    elements.add((Element) nodeList.item(i));
return elements;
ListtoList(final NodeList aList)
to List
final List<T> list = new ArrayList<T>();
for (int x = 0; x < aList.getLength(); ++x) {
    list.add((T) aList.item(x));
return list;
ListtoList(final NodeList nodeList)
Turns a NodeList into a list.
final List<Node> list = new ArrayList<Node>(nodeList.getLength());
for (int nlIndex = 0; nlIndex < nodeList.getLength(); nlIndex++) {
    list.add(nodeList.item(nlIndex));
return list;
ListtoList(final NodeList nodes)
Convert DOM NodeList to List.
final List<T> res = new ArrayList<>(nodes.getLength());
for (int i = 0; i < nodes.getLength(); i++) {
    res.add((T) nodes.item(i));
return res;
ListtoList(NodeList nodes)
to List
int len = nodes.getLength();
ArrayList<Node> list = new ArrayList<Node>(len);
for (int i = 0; i < len; i++) {
    list.add(nodes.item(i));
return list;
Node[]toNodeArray(NodeList list)
to Node Array
int length = list.getLength();
Node[] mRetVal = new Node[length];
for (int i = 0; i < length; ++i) {
    mRetVal[i] = list.item(i);
return mRetVal;
Node[]toNodeArray(NodeList list)
to Node Array
int length = list.getLength();
if (length > 0) {
    Node[] array = new Node[length];
    for (int i = 0; i < length; i++) {
        array[i] = list.item(i);
    return array;
return null;