使用java解析HTML [英] HTML parsing using java

查看:857
本文介绍了使用java解析HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

可能解析HTML文档并构建DOM树(java)

我们用来解析使用DOM,SAX或JDOM的xml。有没有办法解析HTML文件。

Hi, We use to parse the xml using DOM, SAX or JDOM. Is there any way to parse the HTML file.

ex。 :main_file.html

ex. : main_file.html


< div class =Main_Class id =
main_id

style =width =100%; height =100%>

< div class="Main_Class" id = "main_id" style="width="100%;height="100%">

  < div class="sub_class" **id = "sub_id_one"** style="width="50%;height="100%"> </div>
  < div class="sub_class" **id = "sub_id_two"** style="width="50%;height="100%"> </div> 

< / div

< /div

file_two.html

file_two.html


< div style =position:relative;
float:left; width:24%; height:
100%;>

< input type =button
class =buttonvalue =4/>

< div style="position: relative; float: left; width: 24%; height: 100%;>
< input type="button" class="button" value="4"/>
< /div

我要解析主文件,获取sub_id,然后根据相对id附加file_two.html。

I want to parse the main file, get the sub_id and then append the the file_two.html on the basis of relativ id.

推荐答案

我会推荐你要使用HTML Cleaner:

I would recommend you to use the HTML Cleaner:

http:// htmlcleaner。 sourceforge.net/

这篇关于使用java解析HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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