Java XML Child Get getChild(Element element, String name)

Here you can find the source of getChild(Element element, String name)

Description

Get the first child element with the given name.

License

Apache License

Parameter

Parameter Description
element The parent element
name The child element name

Return

The child element or null

Declaration

public static Element getChild(Element element, String name) 

Method Source Code

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

import org.w3c.dom.Element;

public class Main {
    /**// w  w w  . jav a 2 s.  com
     * Get the first child element with the given name.
     *
     * @param element The parent element
     * @param name The child element name
     * @return The child element or null
     */
    public static Element getChild(Element element, String name) {
        return (Element) element.getElementsByTagName(name).item(0);
    }
}

Related

  1. getChild(Element el, String name)
  2. getChild(Element element, String child)
  3. getChild(Element element, String name)
  4. getChild(Element element, String name)
  5. getChild(Element node, String tagName)
  6. getChild(Element parent, int i)
  7. getChild(Element parent, String element)
  8. getChild(Element parent, String name)