Reputation: 4657
This may be a silly question, but is it possible to make a query using XPath without specifying the element name? Normally I would write something like
//ElementName[@id = "some_id"]
But the thing is I have many (about 40) different element types with an id
attribute and I want to be able to return any of them if the id fits. But I don't want to make this call for each type individually. Is it possible to search all of them at once, regardless of the name?
I am using this in an XQuery script, if that offers any help.
Upvotes: 3
Views: 164
Reputation: 327
It might be more efficient to look directly at the @id elements - //* will work, but will initially return every node in the document and then filter!
That may not matter in a small document, of course. but here's an alternative:
//@id[.="some_id"]/..
Upvotes: 1