Como convertir un objeto XML Document a un String
import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import java.io.ByteArrayOutputStream;
public String Document2String(Document doc) {
String xml = "";
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(out, format);
writer.write(doc);
writer.close();
xml = out.toString();
out.close();
} catch (Exception e) {
}
return xml;
}
3 comentarios