Search for matching XML elements from sequence using XPath

Viewed 191

I tried to write query //*[contains(//*/@*[name() != 'id'], ./@id)] but was unlucky. Part of a query //*/@*[name() != 'id'] finds sequence of attribute values and I want to find elements from this sequence which contains ./@id but function contains can't operate with sequence and I don't know how to iterate through elements in sequence in XPath (I need to use only XPath).

How can I solve this?

Any help appritiated.

1 Answers

Apply contains() check on individual attribute which name isn't equal 'id'. The following XPath will return element where at least one of the attribute pass the 'contains' check :

//*[@*[name() != 'id' and contains(., ../@id)]]

demo: link1, link2

Related