gpt4 book ai didi

html - Xpath - 和问题

转载 作者:行者123 更新时间:2023-11-27 22:58:43 28 4
gpt4 key购买 nike

如何使用 xpath 从动态网站中选择特定元素?让我们在下表中说:我想选择第二行,

  • a 列是“好的”
  • c 列为空
  • d 列是“可用”

我打算选择带有“icon_edit”的输入图像作为源,但使用我当前的 xpath,它选择了其中两个。

  //*[normalize-space(td[1])="ok" and not(normalize-space(td[3])) and normalize-space(td[4]="Available")]//*[contains(@src, "icon_edit")]

<html>
<body>
<table>
<tbody>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
<th>f</th>
<th>Actions</th>
</tr>
<tr>
<td><span>ok</span></td>
<td><span>has date</span></td>
<td><span>has date</span></td>
<td><span>Available</span></td>
<td><span>1</span></td>
<td><span></span></td>
<td><input type="image" src="../../Images/icon_edit_Grey.gif">
<input type="image" src="../../Images/icon_delete_Grey.gif">
</td>
</tr>
<tr>
<td><span>ok</span></td>
<td><span>has date</span></td>
<td><span></span></td>
<td><span>Available</span></td>
<td><span>1</span></td>
<td><span></span></td>
<td><input type="image" src="../../Images/icon_edit_Grey.gif">
<input type="image" src="../../Images/icon_delete_Grey.gif">
</td>
</tr>
<tr>
<td><span>ok</span></td>
<td><span>has date</span></td>
<td><span></span></td>
<td><span>Not Available</span></td>
<td><span>1</span></td>
<td><span></span></td>
<td><input type="image" src="../../Images/icon_edit_Grey.gif">
<input type="image"src="../../Images/icon_delete_Grey.gif">
</td>
</tr>
<tr>
<td><span>Not ok</span></td>
<td><span>has date</span></td>
<td><span></span></td>
<td><span>Available</span></td>
<td><span>2</span></td>
<td><span></span></td>
<td><input type="image" src="../../Images/icon_edit_Grey.gif">
<input type="image" src="../../Images/icon_delete_Grey.gif">
</td>
</tr>
<table>
</body>
</html>

最佳答案

您在第三个谓词中打错了字。只需更换

normalize-space(td[4]="Available")

normalize-space(td[4])="Available"

请注意 normalize-space(td[4]="Available") 始终返回 truenormalize-space(td[4])="Available" 如果满足要求的条件则返回 true

关于html - Xpath - 和问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53831766/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com