XPath OR operator for different nodes

前端 未结 3 901
刺人心
刺人心 2020-11-27 15:14

How can I do with XPath:

//bookstore/book/title or //bookstore/city/zipcode/title

Just //tit

相关标签:
3条回答
  • 2020-11-27 16:00

    If you want to select only one of two nodes with union operator, you can use this solution: (//bookstore/book/title | //bookstore/city/zipcode/title)[1]

    0 讨论(0)
  • 2020-11-27 16:12

    All title nodes with zipcode or book node as parent:

    Version 1:

    //title[parent::zipcode|parent::book]
    

    Version 2:

    //bookstore/book/title|//bookstore/city/zipcode/title
    
    0 讨论(0)
  • 2020-11-27 16:17

    It the element has two xpath. Then you can write two xpaths like below:

    xpath1 | xpath2

    Eg:

    //input[@name="username"] | //input[@id="wm_login-username"]
    
    0 讨论(0)
提交回复
热议问题