Can I select multiple options using xpath?

/html/body/form/select/option[@val = '1' and @val = '3']

so what does it mean to choose the first and third options in the form of multiple form?

+5
source share
3 answers

Did you mean or?

/html/body/form/select/option[@val = '1' or @val = '3']

This should select both items. Using and, you are trying to select an element that valhas 1and 3that will not work. :-)

+3
source

To be clear, by choice you mean that it returns these nodes in the results, right? Really doesn't select it in the DOM?

Anyway, you want the following:

 /html/body/form/select/option[1|3]

or

 /html/body/form/select/option[position()=1|postion()=3]

| "", "", , , 1 3, . , 1 3.

+1

. ( ) node , , - val 1 3 . , and or, node, :

/html/body/form/select/option[@val = '1' or @val = '3']

: , , position() .

0

All Articles