What is the correct XPath for choosing attributes that contain “foo”?

后端 未结 9 1630
予麋鹿
予麋鹿 2020-11-27 11:15

Given this XML, what XPath returns all elements whose prop attribute contains Foo (the first three nodes):


 

        
9条回答
  •  孤独总比滥情好
    2020-11-27 11:55

    This XPath will give you all nodes that have attributes containing 'Foo' regardless of node name or attribute name:

    //attribute::*[contains(., 'Foo')]/..
    

    Of course, if you're more interested in the contents of the attribute themselves, and not necessarily their parent node, just drop the /..

    //attribute::*[contains(., 'Foo')]
    

提交回复
热议问题