The main thing is the union operator |, which you tried to use as "or". Change it to or:
./ratings/rating/agency[text()='SNP' or text()='SP']/../code
Or, more naturally,
ratings/rating[agency[. = 'SNP' or . = 'SP']]/code
In XPath 2.0, you can use the sequence:
ratings/rating[agency = ('SNP', 'SP')]/code
Larsh source
share