Reputation: 1
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
Upvotes: 0
Views: 109
Reputation: 11
You can add a nested loop for the illustration.
for $book in /book
let $title := $book/title
let $author := $book/author
for $illustration in $book/illustration
let $nombre := $illustration/name
return ...
Upvotes: 0