如何 select 子元素满足给定条件的所有元素
How to select all elements where child element satisfies given condition
作为该部分代码的示例:
<?xml version="1.0" encoding="iso-8859-1"?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book>
</bookstore>
使用 python 和 selenium 我尝试 select 所有价格低于 30 的书(假设列表可以更大)。
我知道在找到合适的价格后,我可以 select 父元素,例如:
//book/price[..]
我找到了一些方法来 select 具有特定子元素或 value/text 子元素的元素,但我不确定如何根据条件检查它,我就是无法将它们粘合在一起.我很感激任何建议。当然可以是 css select 或 xpath select 或者,任何更适合的。
这行得通吗?
//bookstore/book[price<30]
作为该部分代码的示例:
<?xml version="1.0" encoding="iso-8859-1"?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book>
</bookstore>
使用 python 和 selenium 我尝试 select 所有价格低于 30 的书(假设列表可以更大)。 我知道在找到合适的价格后,我可以 select 父元素,例如:
//book/price[..]
我找到了一些方法来 select 具有特定子元素或 value/text 子元素的元素,但我不确定如何根据条件检查它,我就是无法将它们粘合在一起.我很感激任何建议。当然可以是 css select 或 xpath select 或者,任何更适合的。
这行得通吗?
//bookstore/book[price<30]