Here you can find the source of loadXml(String xml)
public static Document loadXml(String xml)
//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 {// w w w .j av a2s .c o m DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(inputSource); return doc; } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); } } }