gpt4 book ai didi

android - 如何获取文档对象的字符串内容(包括标记)?

转载 作者:行者123 更新时间:2023-11-29 16:24:04 24 4
gpt4 key购买 nike

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder 生成器 = factory.newDocumentBuilder();

文档 doc = builder.newDocument();

//这里追加一些 child ....(此应用程序应在 android API 4 上运行)问题是:如何获取“文档”的文本内容(包括标记)?如果有人能给我一些建议,我将不胜感激。谢谢~!

最佳答案

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

关于android - 如何获取文档对象的字符串内容(包括标记)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5578133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com