【发布时间】:2012-04-28 00:05:30
【问题描述】:
我需要从这样的节点中提取文本:
<div>
Some text <b>with tags</b> might go here.
<p>Also there are paragraphs</p>
More text can go without paragraphs<br/>
</div>
我需要构建:
Some text <b>with tags</b> might go here.
Also there are paragraphs
More text can go without paragraphs
Element.text 只返回 div 的所有内容。 Element.ownText - 不在子元素中的所有内容。两者都是错误的。遍历children 会忽略文本节点。
是否有办法迭代元素的内容以接收文本节点。例如
- 文本节点 - 一些文本
- 节点 - 带有标签
- 文本节点 - 可能在此处。
- 节点
- 还有段落
- 文本节点 - 更多文本可以不带段落
- 节点
-
【问题讨论】:
标签: java iteration jsoup text-extraction