Here you can find the source of findAllNodes(Node node, String[] nodeNames, ArrayList results)
static private void findAllNodes(Node node, String[] nodeNames, ArrayList results)
//package com.java2s; /******************************************************************************* * Copyright (c) 2003, 2006 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:/*from w w w. j a va 2 s . c o m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { static private void findAllNodes(Node node, String[] nodeNames, ArrayList results) { NodeList nodes = node.getChildNodes(); if (nodes != null) { for (int i = 0; i < nodes.getLength(); i++) { for (int j = 0; j < nodeNames.length; j++) { if (nodes.item(i).getNodeName().equals(nodeNames[j])) { results.add(nodes.item(i)); } } findAllNodes(nodes.item(i), nodeNames, results); } } } }