简体   繁体   English

JSoup 无法解析 tr 标签

[英]JSoup couldn't parse tr tag

I am trying to parse String value to JSoup Document as follows:我正在尝试将字符串值解析为 JSoup 文档,如下所示:

    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.但是,JSoup 似乎无法解析我的 String 值中的任何<tr>标记。

Apparently JSoup couldn't parse <tr> tag directly without <table> tag outside <tr> tag.显然JSoup无法分析<tr>标签的情况下直接<table>标签外<tr>标记。 So, i added <table> tag to the value like below and it solves the problem:因此,我将<table>标记添加到如下所示的值中,它解决了问题:

    String value = "<table> <tr> <td>Value</td> </tr> </table>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM