From this Stack Overflow answer, I can see how to match on any attribute values that start with a particular string. For example, finding a list of elements that have any attribute with a value starting with the letter h:
//*[@*[starts-with(., 'h')]]
My question is how to match attribute names that start with a particular string?
As I understand it, the @*
indicates matching any attribute within the wider //*
collection of any elements. The starts-with
function takes two parameters, the haystack and the needle, and the .
haystack indicates the attribute value. I feel like I'm 90% of my way there, but I can't figure out what I need to match on the attribute name, rather than value.
Example matches:
<example>
<first match-me="123">MATCH!</first>
<second do-not-match-me="456">NO MATCH!</second>
<third match-me-yes-please="789">MATCH!</third>
<fourth>
<fifth match-me:oh-yes>MATCH!</fifth>
</fourth>
</example>