Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; public class Main { private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); public static Document parseDocumentByString(String result) { try { factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new ByteArrayInputStream(result.getBytes("UTF-8"))); } catch (Exception ex) { ex.printStackTrace(); } return null; } public static void parseDocumentByString(String result, DefaultHandler defaultHandler) { try { SAXParserFactory sf = SAXParserFactory.newInstance(); SAXParser sp = sf.newSAXParser(); sp.parse(new ByteArrayInputStream(result.getBytes("UTF-8")), defaultHandler); } catch (Exception ex) { ex.printStackTrace(); } } }