a problem about xml format for printing
I get a xml Document object,and convert it to a String,print it in the end.
The codes i used is as follows:
DOMSource source = new DOMSource(script);
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
try {
TransformerFactory tFactory=TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(); transformer.transform(source,result);
}catch(TransformerConfigurationException e) {
System.err.println("not possible to create a Transformer instance: " + e);
}catch(TransformerException e2) {
System.err.println("transform err: " + e2);
}
String xmlString = sw.toString();
System.out.println(xmlString);
The out is like this:
<?xml version="1.0" encoding="UTF-8"?><msml version="1.1"><dialogstart><play><audio uri="file://clip1.wav"/></play></dialogstart></msml>
just print every token sequentially.
But i want a hiberarchy struct with indentions
How can i achieve this.
thanks

