Java XML Node Name getDescendent(Node node, String nodeName)

Here you can find the source of getDescendent(Node node, String nodeName)

Description

get Descendent

License

Open Source License

Declaration

public static Node getDescendent(Node node, String nodeName) throws IOException 

Method Source Code


//package com.java2s;
/*//from www . j a va 2  s  . co  m
 * XmlUtil.java
 *
 * (c) 2009  The Echo Nest
 * See "license.txt" for terms
 *
 *
 */

import java.io.IOException;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Node getDescendent(Node node, String nodeName) throws IOException {
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if (child.getNodeName().equals(nodeName)) {
                return child;
            }
        }
        return null;
    }
}

Related

  1. getAllNodes(Node node, String[] nodeNamesArray)
  2. getBeanElement(Node elem, String nodeName)
  3. getIntegerNodeValue(Node node, String nodeName)
  4. getName(Node node)
  5. getName(Node node)
  6. getName(Node node)