Find CURRENTLY selected

后端 未结 4 1230
醉话见心
醉话见心 2021-01-04 06:42

What\'s the correct XPath syntax to check if an option element is currently selected, or just to get the selected option

4条回答
  •  太阳男子
    2021-01-04 07:05

    I think we can use a knowledge from @Mark's answer and account that. Let's just find a node which HAS desired attribute:

    tree.xpath('//select/option[@selected]/text()')[0].strip()
    

提交回复
热议问题