I have sample XML like this:
<users>
<user name="user1">
<roles separator=",">ADM,USER</roles>
</user>
<user name="user2">
<roles separator=",">ADM,GUEST</roles>
</user>
<user name="user3">
<roles separator=",">READER,GUEST</roles>
</user>
</users>
Is there any way to get all users who are in role GUEST using XPath expression ?
If you’re able to use XSLT 2.0 I would suggest you to tokenize the string of roles. Using
contains()is fine as long as you don’t start having role names like “EXTERNALGUEST” or similar since it would match that aswell.This XPath will tokenize the
rolesdepending on the@separatorand return the users which has this role.