我需要解析非格式良好的xml数据(HTML) [英] I need to parse non well-formed xml data (HTML)

查看:163
本文介绍了我需要解析非格式良好的xml数据(HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JAVA中有一些格式不正确的xml(HTML)数据,我使用了JAXP Dom,但它抱怨。

I have some non well-formed xml (HTML) data in JAVA, I used JAXP Dom, but It complains.


问题是:有没有办法让
使用JAXP来解析这些文件?

The Question is :Is there any way to use JAXP to parse such documents ??

我有一个包含数据的文件as:

I have a file containing data such as :

<employee>
 <name value="ahmed" > <!-- note, this element is not closed, So it is not well-formed xml-->
</employee>


推荐答案

不是真的。 JAXP需要格式良好的标记。您是否考虑过 Cyber​​neko HTML Parser ?我们在我们的商店非常成功。

Not really. JAXP wants well-formed markup. Have you considered the Cyberneko HTML Parser? We've been very successful with it at our shop.

编辑:我发现你也想要解析XML。 Hrmm .... Cyber​​neko适用于HTML,但我不了解其他人。它有一个标签平衡器可以关闭一些标签,但我不知道你是否可以训练它来识别不是HTML的标签。

I see you are wanting to parse XML too. Hrmm.... Cyberneko works well for HTML but I don't know about others. It has a tag balancer that would close some tags off, but I don't know if you can train it to recognize tags that are not HTML.

这篇关于我需要解析非格式良好的xml数据(HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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