'How read with xQuery several similar nodes?

Let's imagine I have an XML with the following structure:

<book>
 <title>My car is red</title>
 <author>Jhon Doe</author>
 <date>05-21-2021</date>
 <illustration>
    <name>front.jpg</name>
 </illustration>
 <illustration>
    <name>back.jpg</name>
 </illustration>
</book>

The node is repeated several times. With a xQuery I can read all nodes :

for $book in /book
 let $title := $book/title
 let $author := $book/author
return
 ....

But I want extract from XML file the name of the two illustration.

I try whit the following code:

for $illustration in $book/illustration
let $nombre := $illustration/name

But only read the name of the last node

How could I do it?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source