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

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

Description

get Node

License

BSD License

Declaration

public static Node getNode(Node node, String nodeName) 

Method Source Code


//package com.java2s;
//License from project: BSD License 

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

public class Main {
    public static Node getNode(Node node, String nodeName) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {

            Element el = (Element) node;
            NodeList nodeList = el.getElementsByTagName(nodeName);
            if (nodeList.getLength() > 0) {
                return nodeList.item(0);
            }/*from  w  w w  .  j a v a 2 s.c  o  m*/

        }

        return null;
    }
}

Related

  1. getName(Node node)
  2. getName(Node node)
  3. getNode(final Node iNode, final String iNodeName)
  4. getNode(Node iNode, String iNodeName)
  5. getNode(Node iNode, String iNodeName)
  6. getNode(Node node, String nodeName)
  7. getNodeContent(Node item, String nodeName)
  8. getNodeContent(Node n, String nodename)
  9. getNodeName(Node node)