使用xpath获取背景图片网址 [英] Get background-image url using xpath
本文介绍了使用xpath获取背景图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试检索URL形式的背景图像.到目前为止,我已经设法获得样式,但是我似乎无法仅获得URL.
I'm trying to retrieve an url form background-image. So far i've managed to get the style however i can't seem to only get url.
我到目前为止所做的:
//div[@class='opponent opponent1']/div[@class='team-player']/@style
HTML示例:
<div class="opponent opponent1">
<div class="team-player" style="background-image: url('/uploads/test.jpeg')"></div>
<h3><a href="#">Team EnVyUs</a></h3>
</div>
推荐答案
The combination of substring-before
and substring-after
should do the trick:
substring-before(substring-after(//div[@class='opponent opponent1']/div[@class='team-player']/@style, "background-image: url('"), "')")
这篇关于使用xpath获取背景图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文