Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2003, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ import java.util.*; import org.w3c.dom.*; public class Main { /** * Return an iterator for the subelements. * @return java.util.Iterator * @param element org.w3c.dom.Element * @param name java.lang.String */ public static Iterator getNodeIterator(Element element, String name) { List<Node> list = new ArrayList<Node>(); NodeList nodeList = element.getElementsByTagName(name); int length = nodeList.getLength(); for (int i = 0; i < length; i++) list.add(nodeList.item(i)); return list.iterator(); } }