Here you can find the source of getErrorText(Document xml)
public static String getErrorText(Document xml)
//package com.java2s; //License from project: MIT License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static String getErrorText(Document xml) { NodeList errorNodes = xml.getElementsByTagName("error"); if (errorNodes.getLength() > 0) { Element errorElement = (Element) errorNodes.item(0); return getElementText(errorElement); }//from ww w . j av a2s .c o m return null; } public static String getElementText(Element element) { StringBuilder text = new StringBuilder(); NodeList childNodes = element.getChildNodes(); int numChildren = childNodes.getLength(); for (int j = 0; j < numChildren; j++) { text.append(childNodes.item(j).getNodeValue()); } return text.toString(); } }