gpt4 book ai didi

java - 如何使用 JSoup 在包含特定属性值的 div 之后添加

转载 作者:太空宇宙 更新时间:2023-11-04 14:17:53 24 4
gpt4 key购买 nike

我有以下 html :

<div type= "HEADER"> hello there </div>

我想插入一个 <br></br>之后。

这是我到目前为止尝试过的方法,但不幸的是它不起作用:

Document doc = Jsoup.parse("<div type= \"HEADER\"> hello there </div>");
doc.select("[type=*HEADER]").after("<br></br>");

那么,你有什么建议?

最佳答案

您的选择器有误。你有:

doc.select("[type=*HEADER]")

但它应该是:

doc.select("[type*=HEADER]")

参见 selector documentation.

关于java - 如何使用 JSoup 在包含特定属性值的 div 之后添加 <br>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20759712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com