Xpath:最终节点上的规范化空间

时间:2017-07-25 06:20:50

标签: xpath

基本的Xpath问题:我使用桌面应用程序来抓取网页,在路径下的span标记中找到数字金额。

//div[contains(@class,'ProductDetailInfoBlock-pricing-amount')]/span

$ 35.12(仅在范围内)回来时,周围有各种空格和9个换行符。如何将normalize-space()应用于span中找到的结果?

申请表不允许:

normalize-space(//div[contains(@class,'ProductDetailInfoBlock-pricing-amount')]/span)

如何完成 - 将其应用于/ span?谢谢!

1 个答案:

答案 0 :(得分:0)

试试这个:

normalize-space(//div[contains(@class,'ProductDetailInfoBlock-pricing-amount')]/span/text())

最后添加/text(),因为您正在尝试规范化它,而不是节点)

相关问题