Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 Jsoup 我试图找到错误的 html 结构,例如:
<body><p><h1>some text</h1></p></body>
我首先选择标题标签,然后使用headingElement.parent()来获取此h1标签的父级。但我得到的不是p它的父母body。有谁知道为什么?
headingElement.parent()
h1
p
body
JSoup 在解析 HTML 时,就像任何好的 HTML 解析器一样,已经应用了<h1>标签自动关闭任何打开<p>元素的规则,因此<p>和<h1>已经<body>是 DOM 中元素的兄弟子级。
<h1>
<p>
<body>