Java tutorial
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document getDocument(String xmlDocument) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new ByteArrayInputStream(xmlDocument.getBytes("UTF-8"))); } catch (Exception e) { throw new RuntimeException("Error parsing XML document", e); } } }