XPath partial of attribute known

前端 未结 2 1980

I know the partial value of an attribute in a document, but not the whole thing. Is there a character I can use to represent any value? For example, a value of a label for

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 06:28

    Your XPath expression should look like this:

    //td[contains(@label, 'Choice 1')]/input
    

    You select all td elements that have a label that contains Choice 1 and then you select the input elements inside these td elements.

    EDIT: Tomalak's comment correctly suggests an improvement to prevent a match against 'Choice 11' (or 'Choice 12345', ...).

提交回复
热议问题