Java XML Child Node Get getChildNode(Node n, String name)

Here you can find the source of getChildNode(Node n, String name)

Description

get Child Node

License

Open Source License

Declaration

public static Node getChildNode(Node n, String name) 

Method Source Code

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

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

public class Main {
    public static Node getChildNode(Node n, String name) {
        if (n == null) {
            throw new IllegalArgumentException("null node");
        }/*  w  w w.  j  a v a2 s  . co  m*/
        if (name == null) {
            throw new IllegalArgumentException("null name");
        }
        NodeList l = n.getChildNodes();
        for (int i = 0; i < l.getLength(); i++) {
            Node node = l.item(i);
            if (name.equals(node.getLocalName())) {
                return node;
            }
        }
        return null;
    }
}

Related

  1. getChildElements(Node parent)
  2. getChildElements(Node parent)
  3. getChildElements(Node start)
  4. getChildElements(NodeList list)
  5. getChildNode(Element item, String name)
  6. getChildNode(Node n, String name)
  7. getChildNode(Node node, int index)
  8. getChildNode(Node node, String childName)
  9. getChildNode(Node node, String name)