How to get String content of Document object(including markup)?
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
//here append some children.... (this application should run on andoroid API 4) the problem is : how can I get the text content(including markup) of the "d开发者_运维技巧oc" ? I will appreciated if someone can give me some advice. Thanks~!
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter sw = new StringWriter();
t.transform(new DOMSource(d), new StreamResult(sw));
System.out.println(sw.toString());
精彩评论