【发布时间】:2015-02-28 07:47:49
【问题描述】:
我正在尝试将<div class="wrapper"> 添加到我生成的 html 之后的 body 标记。我希望结尾 </div> 在结尾 </body> 之前。到目前为止我有
private String addWrapper(String html) {
Document doc = Jsoup.parse(html);
Element e = doc.select("body").first().appendElement("div");
e.attr("class", "wrapper");
return doc.toString();
}
我得到了
</head>
<body>
</head>
<p>Heyo</p>
<div class="wrapper"></div>
</body>
</html>
我也无法弄清楚为什么我在 html 中也出现了“”。我只有在使用 JSoup 时才能得到它。
【问题讨论】:
标签: html html-parsing jsoup