【发布时间】:2018-07-25 23:20:41
【问题描述】:
我有一些看起来像这样的 HTML:
<tr>
<td>
Some text that is interrupted by an image here:
<a href="/item" title="item"><img alt="imageName.png" src="linkhere" width="18" height="18"></a>
and then continues here.
</td>
</tr>
基本上我只需要一种方法来遍历此处的节点,然后使用 JSoup 将文本或图像 alt 添加到字符串中,从而保持节点的顺序。
最后应该是这样的:
此处被图片打断的一些文字:“imageName.png”,然后在此处继续
到目前为止,我可以通过以下方式单独获取图像或文本:
element.text();
//or
element.select("img").attr("alt")
但我无法将它们都放入有序列表中。
有什么想法吗?
【问题讨论】: