Xpath的选择属性的一部分 [英] Xpath select only part of an attribute

查看:155
本文介绍了Xpath的选择属性的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果

/dt/@id

收益 comment_34232 comment_12 我怎么可以让它返回 34232 12 (即进行更换'评论_

returns comment_34232 or comment_12 how can I make it return 34232 or 12 (in other words replaceing 'comment_' with ''

如果

/span/style

收益宽度:80%; 我怎么能代替宽度,之后 %; 检索 80

returns width: 80%; how can I replace width: and after that %; to retrieve 80

问候

推荐答案

我。部分

如果

/dt/@id returns `comment_34232` or `comment_12` how can I make it return


  
  

34232 12 (换句话说
  进行更换'评论_

使用

substring-after(/dt/@id, '_')

II。部分

如果

/span/style returns `width: 80%;` how can I replace  `width: ` and after

这是%; 检索 80

使用

substring-before(substring-after(/span/style, ' '), '%')

待办事项:使用标准的XPath函数的 子串的前() 和的 子串的后()

Do note: the use of the standard XPath functions substring-before() and substring-after() .

这篇关于Xpath的选择属性的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆