FLWOR + HTML لـ XQuery
- الصفحة السابقة XQuery FLWOR
- الصفحة التالية مصطلحات XQuery
XML instance document
we will continue to use this "books.xml" document in the following example (the same as the file in the previous section).
submit the result in an HTML list
see the following XQuery FLWOR expression:
for $x in doc("books.xml")/bookstore/book/title order by $x return $x
the above expression will select all title elements under the book element under the bookstore element and return the title elements in alphabetical order.
now, we want to use an HTML list to list all the books in our bookstore. We add <ul> and <li> tags to the FLWOR expression:
<ul> { for $x in doc("books.xml")/bookstore/book/title order by $x return <li>{$x}</li> } </ul>
the result of the above code is:
<ul> <li><title lang="en">Everyday Italian</title></li> <li><title lang="en">Harry Potter</title></li> <li><title lang="en">Learning XML</title></li> <li><title lang="en">XQuery Kick Start</title></li> </ul>
now we want to remove the title element and only display the data inside the title element.
<ul> { for $x in doc("books.xml")/bookstore/book/title order by $x return <li>{data($x)}</li> } </ul>
النتيجة ستكون قائمة HTML:
<ul> <li>الإيطالية اليومية</li> <li>هاري بوتر</li> <li>تعلم XML</li> <li>بداية XQuery</li> </ul>
- الصفحة السابقة XQuery FLWOR
- الصفحة التالية مصطلحات XQuery