Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { public static Document fromString(String text) { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(text); doc.getDocumentElement().normalize(); return doc; } catch (IOException | ParserConfigurationException | SAXException e) { } return null; } }