Select element whose child/grandchildren/.. contains an element with a specified pattern

NoIdeaHowToFixThis

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

Zero Piraeus

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Select element whose child/grandchildren/.. contains an element with a specified pattern

From Dev

Xpath: select div that contains class AND whose specific child element contains text

From Dev

Select Element whose ID is attribute in another Element

From Dev

Select element if contains text

From Dev

Select element but deselect specified child of element

From Dev

Select element whose name is contained in another node?

From Dev

Geb select element that contains something

From Dev

Change style of an element which contains a specified word

From Dev

How to remove element by class only if it contains an element with some specified text?

From Dev

JQuery: find element whose class contains value of variable

From Dev

Is it possible to apply CSS to an element whose name contains a particular string?

From Dev

Is it possible to apply CSS to an element whose name contains a particular string?

From Dev

Select an element by the text it contains with Selenium Webdriver

From Dev

PHP, stdClass, select elements contains specifed element

From Dev

CSS select an element that contains specific classes only

From Dev

jq: select only an array which contains element A but not element B

From Dev

select matching elements whose sibling element has a specific class

From Dev

How do I assert an element contains the specified text in FluentAutomation?

From Dev

In pandas, select all columns whose label contains a given string at a specified level

From Dev

Replacing string if it contains specified pattern

From Dev

select array by any element exactly matched to specified value

From Dev

Can I select a DOM element based on an HTML comment it contains?

From Dev

How to select element in Protractor by html attribute when value contains

From Java

How to select id if element contains all data in a list in SQL?

From Dev

SQL Server XQuery to select record if XML Column contains element with value

From Dev

How can I select an element that contains "&nbsp;" within its HTML?

From Dev

Jsoup .select returns empty value but element does contains text

From Dev

Can I select a DOM element based on an HTML comment it contains?

From Dev

jQuery find element using .contains() and select even lines in .relatives()

Related Related

  1. 1

    Select element whose child/grandchildren/.. contains an element with a specified pattern

  2. 2

    Xpath: select div that contains class AND whose specific child element contains text

  3. 3

    Select Element whose ID is attribute in another Element

  4. 4

    Select element if contains text

  5. 5

    Select element but deselect specified child of element

  6. 6

    Select element whose name is contained in another node?

  7. 7

    Geb select element that contains something

  8. 8

    Change style of an element which contains a specified word

  9. 9

    How to remove element by class only if it contains an element with some specified text?

  10. 10

    JQuery: find element whose class contains value of variable

  11. 11

    Is it possible to apply CSS to an element whose name contains a particular string?

  12. 12

    Is it possible to apply CSS to an element whose name contains a particular string?

  13. 13

    Select an element by the text it contains with Selenium Webdriver

  14. 14

    PHP, stdClass, select elements contains specifed element

  15. 15

    CSS select an element that contains specific classes only

  16. 16

    jq: select only an array which contains element A but not element B

  17. 17

    select matching elements whose sibling element has a specific class

  18. 18

    How do I assert an element contains the specified text in FluentAutomation?

  19. 19

    In pandas, select all columns whose label contains a given string at a specified level

  20. 20

    Replacing string if it contains specified pattern

  21. 21

    select array by any element exactly matched to specified value

  22. 22

    Can I select a DOM element based on an HTML comment it contains?

  23. 23

    How to select element in Protractor by html attribute when value contains

  24. 24

    How to select id if element contains all data in a list in SQL?

  25. 25

    SQL Server XQuery to select record if XML Column contains element with value

  26. 26

    How can I select an element that contains "&nbsp;" within its HTML?

  27. 27

    Jsoup .select returns empty value but element does contains text

  28. 28

    Can I select a DOM element based on an HTML comment it contains?

  29. 29

    jQuery find element using .contains() and select even lines in .relatives()

HotTag

Archive