Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法深度克隆JSoup Document对象并返回完全相同的HTML?
我有一个预解析的对象,我只想克隆它,因为我怀疑克隆会比总是再次解析HTML更快。
我试图通过迭代 Document 对象的所有元素来克隆它,但是我没有 doctype 声明等。
PS我当然不希望得到评论......
对于任何节点,您都可以调用 .clone()
这是在功能请求中实现的。
由于我对答案和 OP 对此的评论感到困惑,这是我卑微的研究的结果:-)。
document.clone()生成文档对象及其所有子对象的深层副本。根据文档和我自己的实验,这是真的。
document.clone()