使用TagSoup将HTML页面转换为XHTML [英] HTML page to XHTML with TagSoup

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

问题描述

很抱歉,如果这太简单了,但是我根本找不到教程或TagSoup的Java版本的文档.

Sorry if this is too simple, but I simply couldn't find a tutorial nor the documentation of the Java version of TagSoup.

基本上,我想从互联网上下载HTML网页并将其转换为包含在字符串中的XHTML.我该如何使用TagSoup?

Basically I want to download an HTML webpage from the internet and turn it into XHTML, contained in a string. How can I do this with TagSoup?

谢谢!

推荐答案

类似以下内容:

wget -O - example.com/bad.html | java -jar tagsoup.jar

或者,从Java:

要解析HTML:

To parse HTML:

  • 创建org.ccil.cowan.tagsoup.Parser
  • 的实例
  • 提供您自己的SAX2 ContentHandler
  • 提供引用HTML的InputSource
  • 还有parse()
  • Create an instance of org.ccil.cowan.tagsoup.Parser
  • Provide your own SAX2 ContentHandler
  • Provide an InputSource referring to the HTML
  • And parse()!

这篇关于使用TagSoup将HTML页面转换为XHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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