Mega Code Archive
For each node in certain level
File: Data.xml
title 1
publisher 1
title 2
Publisher 2
File: Query.xquery
{
for $book in doc("Data.xml")/bib/book where $book/publisher = "Publisher 2" return
element book {
attribute year {$book/@year},
element title {$book/title/text()}
}
}
Output:
title 2