Java XML Child Get by Name getChildElement(Node parent, String elementName)

Here you can find the source of getChildElement(Node parent, String elementName)

Description

get Child Element

License

Open Source License

Declaration

public static Node getChildElement(Node parent, String elementName) 

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 getChildElement(Node parent, String elementName) {
        NodeList childNodes = parent.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node childNode = childNodes.item(i);
            if (elementName.equals(childNode.getNodeName()))
                return childNode;
        }//ww w  . j a va  2s.  c  o  m
        return null;
    }
}

Related

  1. getChildElement(final Node parentNode, final String childNodeName)
  2. getChildElement(Node node)
  3. getChildElement(Node node, String childName)
  4. getChildElement(Node parent, String childLocalName, String childNamespaceURI)
  5. getChildElement(Node parent, String childName)
  6. getChildElement(Node parent, String name)
  7. getChildElement(Node start, String name)
  8. getChildElement(NodeList childs, Node parent)
  9. getChildElement(String name, Element el)