Java XML First Child Element getFirstChild(Element tag, String childTagName)

Here you can find the source of getFirstChild(Element tag, String childTagName)

Description

get First Child

License

Open Source License

Declaration

public static Element getFirstChild(Element tag, String childTagName) 

Method Source Code

//package com.java2s;
// are made available under the terms of the Eclipse Public License v1.0

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static Element getFirstChild(Element tag, String childTagName) {
        NodeList nodes = tag.getElementsByTagName(childTagName);
        if (nodes == null || nodes.getLength() == 0) {
            return null;
        }/*from  w  ww .j  a  v a2 s. c  o m*/

        return (Element) nodes.item(0);
    }
}

Related

  1. getFirstChild(Element parent, String childTagName)
  2. getFirstChild(Element parent, String name)
  3. getFirstChild(Element parent, String name)
  4. getFirstChild(Element root)
  5. getFirstChild(Element root, String name)
  6. getFirstChild(final Element el, final String name)
  7. getFirstChild(final Element parent, final String childName)
  8. getFirstChild(final Element parentElem, final String childName)
  9. getFirstChild(Node node, String childName)