Java XML First Child Element getFirstMatchingDeepChildByTagName(final Element e, final String tagName)

Here you can find the source of getFirstMatchingDeepChildByTagName(final Element e, final String tagName)

Description

get First Matching Deep Child By Tag Name

License

LGPL

Declaration

public static Element getFirstMatchingDeepChildByTagName(final Element e, final String tagName) 

Method Source Code

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

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static Element getFirstMatchingDeepChildByTagName(final Element e, final String tagName) {
        NodeList matchingElements = e.getElementsByTagName(tagName);
        if (matchingElements != null) {
            return (Element) matchingElements.item(0);
        } else {//from  w  w w  .ja v a  2  s  . c o  m
            return null;
        }
    }
}

Related

  1. getFirstLevelChildElements(Element parent)
  2. getFirstLevelChildElements(Element parent)
  3. getFirstLevelChildElementsByTagName(Element parent, String elementName)
  4. getFirstLevelChildElementsByTagName(Element parent, String elementName)
  5. getFirstMatchedValueByChildTagName(Node parent, String name)
  6. getFirstNamedChild(Node n, String name)
  7. getFirstNamedChild(Node node, String name)
  8. getFirstNamedChildNode(Element element, String string)
  9. getFirstNamedChildNode(Node root, String nodeName)