Xpath-使用开始方式选择属性 [英] Xpath - Selecting attributes using starts-with

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

问题描述

我试图编写一个xpath表达式,该表达式选择所有具有以CompanyCalendar开头的属性id的div标签.以下是我正在查看的HTML的代码段:

I am trying to write an xpath expression that selects all div tags that have an attribute id that start with CompanyCalendar. Below is a snippet of the HTML that I am looking at:

<td class="some class" align="center" onclick="Calendar_DayClicked(this,'EventCont','Event');">
        <span class="Text"></span>
        <div id="CompanyCalendar02.21" class="Pop CalendarClick" style="right: 200px; top: 235px;"></div>

有多个div,其ID类似于CompanyCalendar02.21,但是对于日历中的每个新月,它们都会更改ID.例如,下个月将是CompanyCalendar02.22.我希望能够选择与CompanyCalendar *相等的所有div *

There are multiple divs that have an id like CompanyCalendar02.21 but for each new month in the calendar, they change the id. For example, the next month would be CompanyCalendar02.22. I would like to be able to select all of the divs that are equal to CompanyCalendar*

我在这方面还很陌生,所以我在网上使用了一些示例,尝试使我的xpath表达式正常工作,但无济于事.任何帮助将不胜感激.

I am rather new at this so I was using some example off the net to try and get my xpath expression to work but to no avail. Any help would be greatly appreciated.

推荐答案

我试图编写一个xpath表达式,该表达式选择所有具有以CompanyCalendar开头的属性id的div标签.

I am trying to write an xpath expression that selects all div tags that have an attribute id that start with CompanyCalendar.

以下表达式可能是您想要的:

The following expression is perhaps what you are looking for:

//div[starts-with(@id,'CompanyCalendar')]

用简单的英语来说是

返回XML文档中所有具有属性id且其属性值以"CompanyCalendar"开头的div元素.

Return all div elements in the XML document that have an attribute id whose attribute value starts with "CompanyCalendar".

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

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