【发布时间】:2020-05-10 14:54:28
【问题描述】:
我正在尝试提取未嵌套在 HTML 元素中的文本。这是HTML
<div class="col-sm-12">
<i class='fa fa-map-marker'></i>theCity
<i class='fa fa-link'></i>theEmail
<i class='fa fa-phone'></i>thePhone1
<i class='fa fa-phone'></i>thePhone2
<b>Fax:</b>theFax
<b>Address:</b>theAddress
</div>
我想得到以下结果
- 城市
- 电子邮件
- 电话1
- 电话2
- 传真
- 地址
如您所见,有不同的格式。 theCity、theEmail、thePhone1 和 thePhone2 具有相似的格式,而 theFax 和 theAddress 具有另一种格式。 我尝试使用以下语句获取这两种类型的数据,但没有成功。
这是我尝试的传真和地址的代码
//b/following-sibling::text()[1]
这是城市、电子邮件和电话数据类型的代码
normalize-space(//div[@class="fa-map-marker"]/following-sibling::text())
我做错了什么?
【问题讨论】:
标签: html xml xpath xpath-2.0 xpath-1.0