考虑以下HTML代码段:
String content = "<div id='id_1' contenteditable='false' data-hb='true' data-hbtype='ifequal' data-inv='' data-body='ifequal' data-code='{{#ifequal eventInfo.eventType "customer"}}'>
<td style="line-height:18px;" align="left">
<font face="Trebuchet MS, arial, helvetica" size="1" color="#58595b" style="font-size:13px;">
This is just to confirm that we've cancelled your <span id='id_2' contenteditable='false' data-hb='true' data-hbtype='variable' data-inv='' data-body='' data-code='{{clientInfo.clientName}}'>clientInfo.clientName</span> parcel as requested.
</font>
</td>
</div>"
在执行Jsoup.parse(content)
时,我的HTML内容正在下方(打印得非常漂亮):
<html>
<head></head>
<body>
<div id="id_1" contenteditable="false" data-hb="true" data-hbtype="ifequal" data-inv="" data-body="ifequal" data-code="{{#ifequal eventInfo.eventType "customer"}}">
<font face="Trebuchet MS, arial, helvetica" size="1" color="#58595b" style="font-size:13px;"> This is just to confirm that we've cancelled your <span id="id_2" contenteditable="false" data-hb="true" data-hbtype="variable" data-inv="" data-body="" data-code="{{clientInfo.clientName}}">clientInfo.clientName</span> parcel as requested.</font>
</div>
</body>
</html>
可以看出,<td>
元素在解析的内容中消失了。有没有人面对同样的,或者我在这里错过了什么?
我也试过https://try.jsoup.org/这是尝试JSoup的一种游乐场,但这也提供了相同的输出。
我应该在这里使用其他HTML解析器吗?