How to find elements by attribute namespace in XPath

后端 未结 4 2004
春和景丽
春和景丽 2020-12-05 01:06

I\'m trying to use XPath to find all elements that have an element in a given namespace.

For example, in the following document I want to find the foo:bar

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 01:12

    You could try

    //*[namespace-uri()='http://foo.example.com' or @*[namespace-uri()='http://foo.example.com']]
    

    It will give you element foo:bar and element doodah (if you change tal:quux to foo:quux in your XML-data):

    
    
      Content
      Content
      Content
    
    

    Is that what you want?

提交回复
热议问题