Here you can find the source of parseDocument(String documentString)
public static Document parseDocument(String documentString)
//package com.java2s; /*/*from w w w . j a v a 2 s. co m*/ * SafeOnline project. * * Copyright 2006-2007 Lin.k N.V. All rights reserved. * Lin.k N.V. proprietary/confidential. Use is subject to license terms. */ import java.io.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Main { /** * Parses the given string to a DOM object. */ public static Document parseDocument(String documentString) { try { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); StringReader stringReader = new StringReader(documentString); InputSource inputSource = new InputSource(stringReader); return domBuilder.parse(inputSource); } catch (IOException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } } }