用于 Java 的 HTML/XML 解析器 [英] HTML/XML Parser for Java

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

问题描述

哪些 HTML 解析器具有以下功能:

  • 快速
  • 线程安全
  • 可靠且无错误
  • 解析 HTML 和 XML
  • 处理错误的 HTML
  • 有一个 DOM 实现
  • 支持 HTML4、JavaScript 和 CSS 标签
  • 相对简单的面向对象的 API

你认为哪个解析器更好?

谢谢.

解决方案

Apache Tika 是最佳选择.Apache 最近从现有项目中提取了许多子项目并公开.Tika 是其中之一,以前是 Apache Lucene 的一个组件.由于Apache的支持和声誉以及广泛使用的父项目Lucene,它一定是一个非常好的选择.此外,它是开源的.

Apache Tika 网站的简要介绍:

<块引用>

Apache Tika™ 工具包使用现有的解析器库从各种文档中检测和提取元数据和结构化文本内容.

支持的格式有:

<块引用>

超文本标记语言XML 和派生格式Microsoft Office 文档格式开放文档格式便携式文件格式电子出版物格式富文本格式压缩和打包格式文本格式音频格式图片格式视频格式Java 类文件和档案mbox 格式

What HTML parsers have the following features:

  • Fast
  • Thread-safe
  • Reliable and bug-free
  • Parses HTML and XML
  • Handles erroneous HTML
  • Has a DOM implementation
  • Supports HTML4, JavaScript, and CSS tags
  • Relatively simple, object-oriented API

What parser you think is better?

Thank you.

解决方案

Apache Tika is the best choice. Apache has recently extracted many sub-projects out of the existing projects and made them public. Tika is one of them that was previously a component of Apache Lucene. Because of Apache's support and reputation and the widely-used parent project Lucene it must be a very good choice. Furthermore, it is open-source.

A brief introduction from Apache Tika web site:

The Apache Tika™ toolkit detects and extracts metadata and structured text content from various documents using existing parser libraries.

And the supported formats are:

HyperText Markup Language
XML and derived formats
Microsoft Office document formats
OpenDocument Format
Portable Document Format
Electronic Publication Format
Rich Text Format
Compression and packaging formats
Text formats
Audio formats
Image formats
Video formats
Java class files and archives
The mbox format

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

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