英文:
JSoup couldn't parse tr tag
问题
我正在尝试将字符串值解析为JSoup文档,如下所示:
String value = "<tr> <td>Value</td>> </tr>";
Document htmlDoc = Jsoup.parse(parseTrxRawToHtml);
System.out.println(htmlDoc.html());
代码执行后的结果:
<html>
 <head></head>
 <body>    
 </body>
</html>
但是,似乎JSoup无法解析字符串值中的任何<tr>标签。
英文:
I am trying to parse String value to JSoup Document as follows:
    String value = "<tr> <td>Value</td>> </tr>";
    Document htmlDoc = Jsoup.parse(parseTrxRawToHtml);
    System.out.println(htmlDoc.html());
the result after code has been executed :
<html>
 <head></head>
 <body>    
 </body>
</html>
But, it seems JSoup couldn't parsed any <tr> tag inside my String value.
答案1
得分: 1
显然,JSoup 无法直接解析不带外部 <table> 标签的 <tr> 标签。因此,我按照下面的方式向值中添加了 <table> 标签,解决了这个问题:
    String value = "<table> <tr> <td>Value</td> </tr> </table>"
英文:
Apparently JSoup couldn't parse <tr> tag directly without <table> tag outside <tr> tag.
So, i added <table> tag to the value like below and it solves the problem:
    String value = "<table> <tr> <td>Value</td> </tr> </table>"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论