Converting DOM object to String

Here is a piece of code to convert org.w3c.dom.Document object to string
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
StreamResult result = new StreamResult(new StringWriter());
DOMSource source = new DOMSource(doc);
transformer.transform(source, result);
String xmlString = result.getWriter().toString();

Following needs to be in the import
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;


  1. Currently it looks like Wordpress is the top blogging platform available right now.
    (from what I've read) Is that what you're using on your blog?

  2. Pinyin is the romanized Chinese alphabet" is the place to go when you travel? By talking to family or even five days until you do not know to first learn pinyin. Linguists debate mandarin course whether language structure affects how people feel that Chinese characters! Learning Mandarin Chinese and English, mandarin course French, which is 90.


Post a Comment

Popular posts from this blog

Bengali English word definition in Google Dictionary

Trace India Mobile Number

Load Testing Using Gatling