how to select table column by column header name with xpath

后端 未结 3 1089
礼貌的吻别
礼貌的吻别 2021-02-05 18:57

I have a table of results and it looks like following:

Id&
3条回答
  •  醉酒成梦
    2021-02-05 19:18

    You could use this XPath:

    /table/tbody/tr/td[count(preceding-sibling::td)+1 = count(ancestor::table/thead/tr/th[.='Price']/preceding-sibling::th)+1]
    

    I would think testing the position (position()) of the td against the position of the relevant th would work, but it didn't seem to when I was testing.

提交回复
热议问题