开发者

XPath: Get node below another node

开发者 https://www.devze.com 2023-01-31 20:03 出处:网络
I\'m new to XPath, and I need to get the table node after the following: <p><b>Some unique string</b></p>

I'm new to XPath, and I need to get the table node after the following:

<p><b>Some unique string</b></p>

<center><table>
<tr>
<th>.....

I have been tryin开发者_开发问答g things such as:

"following-sibling::.//p//b[.='Some unique string']"
".//p//b[.='Some unique string']/following:://table"

So far I've managed to get rather stuck and confused, would greatly appreciate a pointer in the right direction. So thank you in advance :)

(If it makes a difference, I'm using the lxml.html module in Python 2.6)


This XPath 1.0 expression:

//b[.='Some unique string']/following::table[1] 

Meaning: the first following table element of any b element in the whole document having 'Some unique string' as string value

0

精彩评论

暂无评论...
验证码 换一张
取 消