Java XML Child Get by Name getChildElement(Element elem, String name)

Here you can find the source of getChildElement(Element elem, String name)

Description

get Child Element

License

Apache License

Declaration

public static Element getChildElement(Element elem, String name) 

Method Source Code

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

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

public class Main {
    public static Element getChildElement(Element elem, String name) {
        NodeList nodes = elem.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name)) {
                return (Element) node;
            }/*  w  w  w . j  a  v  a 2  s  .c  o  m*/
        }
        return null;
    }
}

Related

  1. getChildElemByTagName(Element parent, String tagName)
  2. getChildElement(Element currentNode, String nsURI, String localName)
  3. getChildElement(Element el, String tagName)
  4. getChildElement(Element el, String tagName)
  5. getChildElement(Element ele, String childName)
  6. getChildElement(Element element, String childName)
  7. getChildElement(Element element, String elementName)
  8. getChildElement(Element element, String name)
  9. GetChildElement(Element element, String name)