使用XPath选择字体很棒的图标后立即显示文本

问题描述 投票:1回答:1

我正在尝试提取未嵌套在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>

我想得到以下结果

  • theCity
  • theEmail
  • thePhone1
  • thePhone2
  • theFax
  • theAddress

如您所见,这里有不同的格式。城市,电子邮件,电话1和电话2具有相似的格式,而传真和地址具有另一种格式。我尝试使用以下语句获取两种类型的数据,但没有用。

这是我尝试的传真和地址的代码

//b/following-sibling::text()[1]

这里是城市,电子邮件和电话数据类型的代码

normalize-space(//div[@class="fa-map-marker"]/following-sibling::text())

我在做什么错?

html xml xpath xpath-2.0 xpath-1.0
1个回答
0
投票

我在做什么错?

© www.soinside.com 2019 - 2024. All rights reserved.