Here you can find the source of iterableNodes(final NodeList nodeList)
public static Iterable<Node> iterableNodes(final NodeList nodeList)
//package com.java2s; /*// w w w .j av a 2 s . co m * ao-lang - Minimal Java library with no external dependencies shared by many other projects. * Copyright (C) 2014, 2016, 2017 AO Industries, Inc. * support@aoindustries.com * 7262 Bull Pen Cir * Mobile, AL 36695 * * This file is part of ao-lang. * * ao-lang is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ao-lang is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with ao-lang. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Iterator; import java.util.NoSuchElementException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Iterates over a NodeList. */ public static Iterable<Node> iterableNodes(final NodeList nodeList) { return new Iterable<Node>() { @Override public Iterator<Node> iterator() { return new Iterator<Node>() { int index = 0; @Override public boolean hasNext() { return index < nodeList.getLength(); } @Override public Node next() { if (hasNext()) { return nodeList.item(index++); } else { throw new NoSuchElementException(); } } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; } }; } }