Create Xpath Manually

▼魔方 西西 提交于 2020-01-07 02:11:51

问题


I want to create xpath which must contain word "Asia"

//div[@id='destination-loadLevel0']/div/ul/li/div/div/span *for Asia //div[@id='destination-loadLevel0']/div/ul/li[2]/div/div/span
*for Europe //div[@id='destination-loadLevel0']/div/ul/li[3]/div/div/span *for USA

//<div class="col-md-3 level-column column-viewport" id="destination-loadLevel0">


<div class="row">
<ul>
<li class="col-md-3 col-hotspot unselectable-text" data-parent-group-id="" data-groupid="2244604" data-name="Asia;|03|00|00|">
<div class="tile-container">
<div class="image-label" data-toggle="tooltip" data-container="body" data-placement="top" title="" data-original-title="Asia">
<span class="title ellipsis">Asia</span>
<span class="icon icon-angle-right"></span>
</div>

回答1:


//*[contains(text(),'Asia')] | //@*[contains(.,'Asia')]/parent::*

returns all elements whose text contains 'Asia' or whose attribute values contains 'Asia'

Output :

<li class="col-md-3 col-hotspot unselectable-text" data-parent-group-id="" data-groupid="2244604" data-name="Asia;|03|00|00|" /> <div class="image-label" data-toggle="tooltip" data-container="body" data-placement="top" title="" data-original-title="Asia" /> <span class="title ellipsis">Asia</span>



来源:https://stackoverflow.com/questions/37482315/create-xpath-manually

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!