XPath selecting multiple elements with predicates

前端 未结 3 1643
小蘑菇
小蘑菇 2021-01-04 11:26

I have an XPath query which is doing what I want, namely selecting a union of \'surname\' & \'given-names\' with the given predicates (It\'s actually either/or that I ne

3条回答
  •  耶瑟儿~
    2021-01-04 12:23

    First, this is valid XPath 2.0:

    /header/authors/(surname|given-names)[./text() and @id='1'] 
    

    Second, this XPath 1.0:

    /header/authors/*[self::surname|self::given-names][text()][@id='1'] 
    

提交回复
热议问题