xpath - Python lxml - get selected options -


i'm trying access selected options in select using lxml looks lxml doesn't know property. here code:

for option in productfield.xpath('select//option'):     if 'selected' in option.attrib:         print(option) 

when print(option.attrib) see {'value': 'value...'}. wrong somewhere?

got it.

if (productfield.xpath('select//option[@selected="selected"]')):     option in productfield.xpath('select//option[@selected="selected"]'):         print(option) 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -