我有一个这种html文档:
<html>
<head></head>
<body>
<p>
<dfn>text</dfn>sometext
**<i>othertext</i>**
<i>...</i>
<i>...</i></p>
<p>
<dfn>text</dfn>sometext
**<i>othertext</i>**
<i>...</i>
<i>...</i></p>
</body>
</html>
我需要对其进行解析,以便能够从每个第一个I-tag中获取文本,以及关于dfn的文本(我将最终提取dfn文本) 目前我的代码是:
^{pr2}$这会遍历每个i-tag,有时会给我错误的输出。我如何将迭代限制在dfn的第一个同级?在
找到匹配项时,请退出
itersiblings()
循环:break
语句提前结束for sibling
循环,不再处理其他同级。相反,外部的for dfn
循环继续下一个dfn
元素。在相关问题 更多 >
编程相关推荐