Java XML Node Select selectNode(Node node, String tag)

Here you can find the source of selectNode(Node node, String tag)

Description

select Node

License

Open Source License

Declaration

public static Node selectNode(Node node, String tag) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Node selectNode(Node node, String tag) {
        NodeList nodes = node.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node n = nodes.item(i);
            if (n instanceof Element && ((Element) n).getTagName().equals(tag)) {
                return n;
            }//from w  w  w .j  a v a2 s  .co m
        }
        return null;
    }
}

Related

  1. selectElement(Node node, String uri, String nodeName)
  2. selectNode(Node sibling, String uri, String nodeName, int number)
  3. selectNode(Node sibling, String uri, String nodeName, int number)
  4. selectNode(Node sibling, String uri, String nodeName, int number)
  5. selectNodeByName(Node node, String nodeName)