I am using lxml
, using the html
module of the library.
How can I get the element that contains an element with certain characteristics?
For example:
<TR>
<TD>Welcome</TD>
<TD>other</TD>
</TR>
<TR>
<TD>Bye Bye</TD>
<TD>another</TD>
</TR>
How can I select the <TR>
element which contains the <TD>Welcome</TD>
? Not sure how to write down the proper xpath
pattern
If you want to use XPath, this ought to work:
e = doc.xpath('//tr[td[text()="Welcome"]]')[0]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments