Java XML Child Get getChild(Node node, String name)

Here you can find the source of getChild(Node node, String name)

Description

get Child

License

BSD License

Declaration

public static Element getChild(Node node, String name) 

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 Element getChild(Node node, String name) {
        NodeList list = node.getChildNodes();
        int count = list.getLength();
        for (int i = 0; i < count; i++) {
            Node n = list.item(i);
            if (n.getNodeType() != Node.ELEMENT_NODE)
                continue;
            if (n.getNodeName().equalsIgnoreCase(name))
                return (Element) n;
        }//from ww  w .j  a  v  a2s  .com
        return null;
    }
}

Related

  1. getChild(final Element parent, final String tag)
  2. getChild(final Element root, final String name)
  3. getChild(final Element root, final String name)
  4. getChild(Node n, String name)
  5. getChild(Node node, String name)
  6. getChild(Node node, String name, String attrName, String attrValue)
  7. getChild(Node parent, String name)
  8. getChild(Node parent, String name)
  9. getChildElements(Element e)