Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; import org.xml.sax.InputSource; public class Main { public static Document buildAndParseDocument(String in) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(in)); return db.parse(is); } catch (Exception e) { throw new RuntimeException(e); } } }