I assume you want to go from:
org.dom4j.Document
To:
org.w3c.dom.Document
In a quick start guide with dom4j :
Document document = ...; String text = document.asXML();
From the JavaRanch example in String for the document:
public static Document stringToDom(String xmlSource) throws SAXException, ParserConfigurationException, IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new InputSource(new StringReader(xmlSource))); }
Combine 2, and you should get what you need.
source share