Here you can find the source of iterable(final NodeList list)
@SuppressWarnings("unchecked") public static Iterable<Node> iterable(final NodeList list)
//package com.java2s; /*/*from w w w . java 2s.c o m*/ Copyright (c) 2009-2011 Olivier Chafik, All Rights Reserved This file is part of JNAerator (http://jnaerator.googlecode.com/). JNAerator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JNAerator 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 General Public License for more details. You should have received a copy of the GNU General Public License along with JNAerator. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Collections; import java.util.Iterator; import java.util.NoSuchElementException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { @SuppressWarnings("unchecked") public static Iterable<Node> iterable(final NodeList list) { if (list == null) return Collections.EMPTY_LIST; return new Iterable<Node>() { int nextPos = 0; public Iterator<Node> iterator() { return new Iterator<Node>() { public Node next() { if (nextPos >= list.getLength()) throw new NoSuchElementException(); return list.item(nextPos++); } public boolean hasNext() { return nextPos < list.getLength(); } public void remove() { throw new UnsupportedOperationException(); } }; } }; } }