Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Document; import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.StringReader; public class Main { public static Document loadXml(String xml) { InputSource inputSource = new InputSource(new StringReader(xml)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(inputSource); return doc; } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); } } }