【发布时间】:2016-03-23 03:19:25
【问题描述】:
我正在使用 Jsoup 解析任意 HTML,到目前为止它运行良好,但我遇到了问题。当给定以下 HTML 时,Jsoup 返回无效的 HTML(多余的位被删除):
<div>
<a href=''>
<img src='' alt='The problem is here "I'm not sure what to do"'>
</a>
</div>
我有一个alt 标签,用单引号括起来,其中包含未转义的单引号和双引号,不幸的是我无法控制输入。当我通过Jsoup.parse 运行它时,我得到了这个:
<div>
<a href="">
<img src="" alt="The problem is here "I" m not sure what to do"'>
</a>
</div>
img 标签末尾的那两个未闭合的引文把我搞砸了。我希望 Jsoup 能给我一些类似的东西:
<div>
<a href="">
<img src="" alt="The problem is here "I'm not sure what to do"">
</a>
</div>
有没有办法让这成为可能?
【问题讨论】: