开发者

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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜