Page 1 of 1

XQUERY: return values from different tags using xquery

Posted: Mon Oct 10, 2022 7:37 am
by FramJamesgot
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?

Re: XQUERY: return values from different tags using xquery

Posted: Tue Oct 11, 2022 2:22 pm
by artur_bozieac
Hello FramJamesgot,

I wrote a this XPath :

Code: Select all

./*[self::elementType or self::otherElementType]

For this source :

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<doc>
 <elementType>value</elementType>
 <otherElementType>value</otherElementType>
 <elementType>value</elementType>
 <elementType>value</elementType>
</doc>
It selects elementType either otherElementType.