Mega Code Archive
Categories
/
XML
/
Xquery
Return a if statement
File: Data.xml
title 1
A
B
C
D
title 2
E
F
File: Query.xquery
{for $book in doc("Data.xml")/bib/book return if (count($book/author) gt 2) then
{$book/title/text()}
{count($book/author)}
else () }
Output: