Skip to content Skip to sidebar Skip to footer

Extracting Just-sibling Element In Xpath

I am using this line of code to select this element x=temp_tree.xpath('//font[text()='Put In Longitude : ']/just-sibling::td/font/text()') It is giving an error. Please Correct it

Solution 1:

>>> thingy = tree.xpath('..//font[text()="Put In Latitude : "]/../following-sibling::td/font/text()')
>>> thingy
['47.8034515']

The font you selected doesn't have a sibling. Go back up the tree to the parent td with .. and then down to find the sibling td containing the required item.


Post a Comment for "Extracting Just-sibling Element In Xpath"