forked from LupusNobilis/java-org.hwo
39 lines
718 B
Java
39 lines
718 B
Java
|
package org.hwo.xml;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
|
||
|
import org.w3c.dom.Element;
|
||
|
import org.w3c.dom.Node;
|
||
|
import org.w3c.dom.NodeList;
|
||
|
|
||
|
public class NodeListIterator implements Iterable<Element>{
|
||
|
|
||
|
|
||
|
private List<Element> elements;
|
||
|
|
||
|
public static NodeListIterator create(NodeList nodes)
|
||
|
{
|
||
|
return new NodeListIterator(nodes);
|
||
|
}
|
||
|
|
||
|
public NodeListIterator(NodeList nodes)
|
||
|
{
|
||
|
this.elements = new ArrayList<Element>();
|
||
|
for (int i=0;i<nodes.getLength();i++)
|
||
|
if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE)
|
||
|
{
|
||
|
elements.add((Element)nodes.item(i));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public Iterator<Element> iterator() {
|
||
|
return this.elements.iterator();
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|