Java XML First Child Element getFirstChild(Node node, String childName)

Here you can find the source of getFirstChild(Node node, String childName)

Description

get First Child

License

Apache License

Declaration

public static Node getFirstChild(Node node, String childName) 

Method Source Code

//package com.java2s;
// Written by Tomer Gabel under the Apache License Version 2.0

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

public class Main {
    public static Node getFirstChild(Node node, String childName) {
        NodeList nodeList = node.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node child = nodeList.item(i);
            if (child.getNodeName().equals(childName)) {
                return child;
            }//from  w  ww  . j ava 2  s .c  om
        }
        return null;
    }
}

Related

  1. getFirstChild(Element root, String name)
  2. getFirstChild(Element tag, String childTagName)
  3. getFirstChild(final Element el, final String name)
  4. getFirstChild(final Element parent, final String childName)
  5. getFirstChild(final Element parentElem, final String childName)
  6. getFirstChild(Node parent)
  7. getFirstChildByName(Element parent, String name)
  8. getFirstChildByNodeName(Node parent, String nodeName)
  9. getFirstChildByNS(Element node, String ns, String localName)