Here you can find the source of getNodes(Node iNode, String iNodeName)
Parameter | Description |
---|---|
iNode | The provided node structure to be traversed. |
iNodeName | The name of the node being searched for. |
public static Vector getNodes(Node iNode, String iNodeName)
//package com.java2s; /* Agrega es una federaci?n de repositorios de objetos digitales educativos formada por todas las Comunidades Aut?nomas propiedad de Red.es. Este c?digo ha sido desarrollado por la Entidad P?blica Empresarial red.es adscrita al Ministerio de Industria,Turismo y Comercio a trav?s de la Secretar?a de Estado de Telecomunicaciones y para la Sociedad de la Informaci?n, dentro del Programa Internet en el Aula, que se encuadra dentro de las actuaciones previstas en el Plan Avanza (Plan 2006-2010 para el desarrollo de la Sociedad de la Informaci?n y de Convergencia con Europa y entre Comunidades Aut?nomas y Ciudades Aut?nomas) y ha sido cofinanciado con fondos FEDER del Programa Operativo FEDER 2000-2006 ?Sociedad de la Informaci?n? /*from w ww . j a v a 2 s.c om*/ This program is free software: you can redistribute it and/or modify it under the terms of the European Union Public Licence (EUPL v.1.0). This program 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 European Union Public Licence (EUPL v.1.0). You should have received a copy of the EUPL licence along with this program. If not, see http://ec.europa.eu/idabc/en/document/7330. */ import java.util.Vector; import java.util.logging.Logger; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * This method returns an ordered list containing the desired nodes which is * determined by the provided node name and namespace. * * @param iNode The provided node structure to be traversed. * @param iNodeName The name of the node being searched for. * * @return Returns an ordered list containing the desired nodes. */ public static Vector getNodes(Node iNode, String iNodeName) { Logger.getLogger("org.adl.util.debug.validator").entering("DOMTreeUtility", "getNodes()"); Logger.getLogger("org.adl.util.debug.validator").info("Parent Node: " + iNode.getLocalName()); Logger.getLogger("org.adl.util.debug.validator").info("Node being searched for: " + iNodeName); // Create a vector to hold the results of the method Vector result = new Vector(); // Check to see if the input node is null if (iNode != null) { // Get the set of child nodes of the input node NodeList children = iNode.getChildNodes(); // If there are children nodes loop through them looking for // the node matching the name and namespace if (children != null) { int numChildren = children.getLength(); // Loop over the children searching for the desired node for (int i = 0; i < numChildren; i++) { // get the current child in the list Node currentChild = children.item(i); // Get the local name of the child node String currentChildName = currentChild.getLocalName(); if (currentChildName != null) { // Determine if the current child node is the one that // is being looked for if (currentChildName.equalsIgnoreCase(iNodeName)) { result.add(currentChild); } } } } } return result; } }