如何选择其中没有其他 div 的 div 元素?
我正在使用 Java 和 Jsoup 来解析 HTML 页面,我想获取所有不包含其他 div 的 div 来打印它包含的文本。
但例如,如果一个 div 包含一个表,而该表包含一个 div,我就不需要它。我只想要最底层的 div,里面没有其他 div(其他标签也可以)。
我如何做到这一点?
首先,我想知道是否有一些语法可以与 select()
方法一起使用。
I'm using Java and Jsoup to parse HTML pages and I want to get all the divs that not contains another divs inside it to print the text it contains.
But for example, if a div contains a table, and the table costains a div, I don't want it. I want only the div at the most bottom level, with none another div inside it (another tags are ok).
How I do this?
Primarilly, I want to know if there is some syntax that can I use with the select()
method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)