2009-11-02 140 views

回答

8

你有什么是正确的[?]:

的第二个选项,使用:

/html/body/select/option[2] 

/html/body/select/option[position()=2] 

请参阅http://www.w3.org/TR/xpath#location-paths

编辑

注意的是,上述假设你有如下的结构:

<html> 
    <body> 
    <select> 
    <option></option> 
    <option></option> 
    </select> 
    </body> 
</html> 

如果你的选择是比身体其他家长的里面,那么你要么需要使用这样的:

/html/body/div[@class='header']/select/option[2] 

//select/option[2] 

当然,由于您的选择可能具有名称属性,因此您可以使用该属性

//select[@name='myselect']/option[2]