Java XML NodeList toElementIterable(NodeList nodeList)

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

Description

Converts a NodeList to an Iterable of Elements.

License

Apache License

Declaration

public static Iterable<Element> toElementIterable(NodeList nodeList) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License"); you may not

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

import java.util.ArrayList;
import java.util.List;

public class Main {
    /** Converts a NodeList to an Iterable of Elements. */
    public static Iterable<Element> toElementIterable(NodeList nodeList) {
        List<Element> elements = new ArrayList<>(nodeList.getLength());
        for (int i = 0; i < nodeList.getLength(); i++) {
            elements.add((Element) nodeList.item(i));
        }//from  ww w. j  a  v a2 s.co m
        return elements;
    }
}

Related

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