Search code examples
javajdomjdom-2

Convert jdom2 Document to DOMSource


I have an XML as jdom2 Document delivered by an URIResolver and need to convert it to a DOMSource.

But I have no Clue how I could do that. I know that a org.w3c.dom.Node can be used to create a DOMSource but I also have no glue how to convert a jdom2 Document to a org.w3c.dom.Node.

Can anyone give me some tips or hints how to solve my Problem?


Solution

  • After a little research I found this http://www.jdom.org/docs/apidocs/org/jdom2/output/DOMOutputter.html

    and by using trhe DOMOutputter it is just:

    org.jdom2.Document doc = //some jdom2 Document
    org.w3c.dom.Document outputDom = new DOMOutputter().output(doc);