Java XML First Child Element getFirstChildElement(Element parent, String tagName)

Here you can find the source of getFirstChildElement(Element parent, String tagName)

Description

Get the first child element of a given name a parent element.

License

Apache License

Parameter

Parameter Description
parent The parent element for which the child must be retrieved.
tagName The name of the child that must be retrieved.

Declaration


public static Element getFirstChildElement(Element parent, String tagName) 

Method Source Code

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

import org.w3c.dom.Element;

public class Main {
    /**/* ww w  . java  2  s.c o m*/
     * Get the first child element of a given name a parent element.
     * 
     * @param parent
     *            The parent element for which the child must be retrieved.
     * @param tagName
     *            The name of the child that must be retrieved.
     * @return
     */
    // Get first child element by name
    public static Element getFirstChildElement(Element parent, String tagName) {
        return (Element) parent.getElementsByTagName(tagName).item(0);
    }
}

Related

  1. getFirstChildElement(Element parent)
  2. getFirstChildElement(Element parent)
  3. getFirstChildElement(Element parent, String childName)
  4. getFirstChildElement(Element parent, String nsUri, String localPart)
  5. getFirstChildElement(Element parent, String tagName)
  6. getFirstChildElement(Element parentElem)
  7. getFirstChildElement(Element root)
  8. getFirstChildElement(final Node node)
  9. getFirstChildElement(final Node parent, final String elemName)