Is there a more elegant way to convert an XML Document to a String in Java than this code?

后端 未结 4 1698
轮回少年
轮回少年 2020-11-29 18:42

Here is the code currently used.

public String getStringFromDoc(org.w3c.dom.Document doc)    {
        try
        {
           DOMSource domSource = new DOM         


        
4条回答
  •  执念已碎
    2020-11-29 19:18

    You could use XOM to perhaps do this:

    org.w3c.dom.Document domDocument = ...;
    nu.xom.Document xomDocument = 
        nu.xom.converters.DOMConverter.convert(domDocument);
    String xml = xomDocument.toXML();
    

提交回复
热议问题