user1642468
user1642468

Reputation: 13

XQUERY: reutrn values from different tags using xquery

I´m starting using xquery and I want to know how to get the values from 2 different type of tags. for example:

xml

<elementType>value</elementType>
<otherElementType>value</elementType>
<elementType>value</elementType>
<elementType>value</elementType>

xquery

"for $b in $doc//elementType return stringg($b)" 
"for $b in $doc//otherElementType return stringg($b)" 

I want this but only using one query, how can that be done?

Upvotes: 1

Views: 122

Answers (1)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243449

Use what is possibly the shortest expression:

//*[self::elementType or self::otherElementType]/string()

Upvotes: 2

Related Questions