I would like to know how you could query for one specific language, this is a related XML-snippet:
(...)
<Guide guideID = '5' gname = 'Dexter Schneider'>
<Lang lname = "{'Spanish' , 'German' , 'English'}"/>
</Guide>
(...)
I tried with:
element Result {
//Guide[Lang/@lname = 'German']
}
but I only get the results where “German” is the only language in “lname”. I suspect this is either because of a bad XML-document (no warnings from XQuisitor about the syntax), or because the “=”-sign can only compare one exact string with another. Could anyone shed some light on this, and show me how a proper query would look like? Thanks!
In your specific case, you can use
//Guide[contains(Lang/@lname, 'German')].More generaly, the value of your attribute is a string and not an array.
For your use case, you can use sequences but you first have to build the sequence.
For example, if you have an XML like that :
You can use the following XPath 2.0 syntax (xquery compliant) :
The
tokenizefunction creates a sequence and the=tests what you want.