How to find elements by attribute namespace in XPath

Use:

//*[namespace-uri()='yourNamespaceURI-here'
   or
    @*[namespace-uri()='yourNamespaceURI-here']
   ]

the predicate two conditions are or-ed with the XPath or operator.

The XPath expression thus selects any element that either:

  • belongs to the specified namespace.
  • has attributes that belong to the specified namespace.

I'm not sure if this is what you mean, but by only deleting one char in your XPath you get all elements in a certain namespace:

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