firet
firet

Reputation: 115

XQuery, get element with same value?

xml

<books> <book> <author>Gambardella, Tim</author> </book> <book> <author>Knorr, Stefan</author> </book> <book> <author>O'Brien, Tim</author> </book> </books>

How get authors with same name?

I tried searching but didn't find even working examples for finding the same strings

Upvotes: 0

Views: 94

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

Usually this is a grouping problem e.g.

for $author in books/book/author 
  group by $prename := $author => substring-after(',') => normalize-space() 
return 
  <group prename="{$prename}">{$author}</group>

Upvotes: 1

Related Questions