Here you can find the source of getElement(Element element, String tagName)
public static Element getElement(Element element, String tagName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static Element getElement(Element element, String tagName) { final NodeList nodeList = element.getElementsByTagName(tagName); if (nodeList == null || nodeList.getLength() < 1) { return null; }//from w w w . j ava2 s .com int length = nodeList.getLength(); for (int i = 0; i < length; i++) { Element childEle = (Element) nodeList.item(i); if (childEle == null || childEle.getParentNode() == element) { return childEle; } } return null; } }