XPath with multiple conditions

后端 未结 5 1831
慢半拍i
慢半拍i 2020-11-30 19:24

What XPath can I use to select any category with a name attribute specified and any child node author with the value specified.

I\'ve tried different variations of t

5条回答
  •  不知归路
    2020-11-30 19:26

    Use:

    /category[@name='Sport' and author/text()[1]='James Small']
    

    or use:

    /category[@name='Sport' and author[starts-with(.,'James Small')]]
    

    It is a good rule to try to avoid using the // pseudo-operator whenever possible, because its evaluation can typically be very slow.

    Also:

    ./somename
    

    is equivalent to:

    somename
    

    so it is recommended to use the latter.

提交回复
热议问题