Here you can find the source of getElementWithKeyFromDocument(final Document document, final String key)
public static Element getElementWithKeyFromDocument(final Document document, final String key)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static Element getElementWithKeyFromDocument(final Document document, final String key) { final NodeList nodeList = document.getElementsByTagName(key); Element result = null;//from ww w . j a va 2 s. c o m if (nodeList.getLength() > 0) { result = (Element) nodeList.item(0); } return result; } }