jsoup中的哪些方法可以返回修改后的html? [英] what method in jsoup can return the modified html?

查看:101
本文介绍了jsoup中的哪些方法可以返回修改后的html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 jsoup 解析 html文件(以原生格式存储)时。我修改了html文件中的一些元素,因此我想保存修改过的html,并替换旧的元素。

是否有任何人知道哪种方法 strong>在jsoup可以完成这项工作吗?

非常感谢!!!!

When I parse the html file(stored in native) with jsoup. I have modified some elements in the html file,so I want to save the modified html, and replace the old one?
Do any body know which method in jsoup can do the job?
Thank you so much!!!

推荐答案

写下

document.toString() 

document.outerHtml()

到文件,其中文档 $ b

to file, where document is got from

Document document = Jsoup.connect("http://...").get();
// any document modifications...

如此:

BufferedWriter htmlWriter = 
     new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"));
htmlWriter.write(document.toString());

这篇关于jsoup中的哪些方法可以返回修改后的html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆