Hi All,
I have written a very simple
Java program to write a XML document. I am using the default implementation of DOM provided by Sun, that means javax.xml and org.w3c.dom packages.
Here is the code snippet.
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer();
// The following property is used to create the element in different lines of the xml
transformer.setOutputProperty(OutputKeys.INDENT,"Yes");
Source input = new DOMSource(document); // passing the instance of Document
Result output = new StreamResult(os); // passing the instance of OutputStream
transformer.transform(input , output);
The output created is like this
<root>
<element att=�val1� >
<subElement>text</subElement>
</element>
</root>
I want the output will be like this
<root>
<element att=�val1� >
<subElement>text</subElement>
</element>
</root>
Please help me how can I create the output like the above. Is it possible to create such transformation by sun default DOM implementation? (which I am using).
Regards,
Gourab