Use for loop : for « XQuery « XML

Home
XML
1.CSS Style
2.SVG
3.XML Schema
4.XQuery
5.XSLT stylesheet
XML » XQuery » for 
Use for loop


File: Data.xml

<?xml version="1.0"?>
<cars>
 <car>A</car>
 <car>B</car>
 <car>C</car>
 <car>D</car>
</cars>

File: Query.xquery
<cars>
{for $i in to return <car>{$i}</car>}
</cars>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<cars>
   <car>1</car>
   <car>2</car>
   <car>3</car>
   <car>4</car>
   <car>5</car>
</cars>

 
Related examples in the same category
1.Multiple for clauses
2.Multiple variable bindings in one for clause
3.Nested for loop
4.for loop and node text
5.for each loop and range
6.for each loop
7.Nested for each loop
8.For each node in certain level
9.For stateCt
10.for and doc() function
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.