Here you can find the source of getString(Document doc, String tagName)
public static String getString(Document doc, String tagName) throws Exception
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.NodeList; public class Main { public static String getString(Document doc, String tagName) throws Exception { NodeList values = doc.getDocumentElement().getElementsByTagName( tagName);//from w ww . j a v a2s . c o m if (values.getLength() == 1) { return values.item(0).getTextContent(); } throw new Exception("more than one " + tagName + " elements"); // TODO create custom exception } }