Here you can find the source of getElementByTagName(Element aParent, String aName)
public static Element getElementByTagName(Element aParent, String aName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getElementByTagName(Element aParent, String aName) { Node child = aParent.getFirstChild(); while (child != null) { if (child instanceof Element && ((Element) child).getTagName().equals(aName)) { return (Element) child; }// w w w . ja va 2 s . co m child = child.getNextSibling(); } return null; } }