如何找到具有特定文本的跨度(具有其他html元素) [英] How to find a span (has other html elements) with specific text

查看:86
本文介绍了如何找到具有特定文本的跨度(具有其他html元素)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据跨度中的内容找到列表项目。

I am trying to find the list item based on the contents in the span.

我尝试使用// li / a [contains(。,'Business')]

I tried using //li/a[contains(., 'Business')]

工作的唯一项目,但在这里,它提供了一个列表,因为它匹配多个。

It is working for unique items, But here, it gives a list because it is matching more than one.

我想忽略内部跨度,只关注跨度文本识别李。

I want to ignore the inner span and only focus on the span text to identify the li. How can i achieve it?

<li style="display: list-item;">
    <a href="#">
        <span class="avoidwrap">
            <span class="icomoon-cube3">
            </span> 
            Business
        </span>
    </a>
</li>
<li style="display: list-item;">
    <a href="#">
        <span class="avoidwrap">
            <span class="icomoon-cube3">
            </span> 
            Business Something
        </span>
    </a>
</li>


推荐答案

p>

The answer given by splash58 in comments worked,

//li/a/span[normalize-space(.)='Business']

这篇关于如何找到具有特定文本的跨度(具有其他html元素)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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