XQuery FLWOR + HTML
The XML Example Document
We will use the "books.xml" document in the examples below (same
XML file as in the previous chapters).
View the "books.xml" file in your browser.
Present the Result In an HTML List
Look at the following XQuery FLWOR expression:
for $x in doc("books.xml")/bookstore/book/title
order by $x
return $x
|
The expression above will select all the title elements under the book
elements that are under the bookstore element, and return the title elements in
alphabetical order.
Now we want to list all the book-titles in our bookstore in an HTML list. 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 will be:
<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 eliminate the title element, and show only 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>
|
The result will be (an HTML list):
<ul>
<li>Everyday Italian</li>
<li>Harry Potter</li>
<li>Learning XML</li>
<li>XQuery Kick Start</li>
</ul>
|
What do you want your Web site to do?

What do you want your Web site to do? Ektron CMS400.NET lets you do everything you need to do on the Web and do everything you want to do.
Ektron CMS400.NET gives you all the features you would expect from an
enterprise CMS, but also high-demand functionality like real-time Web
site analytics, community building, blogging, personalization, and
online calendars. Ektron CMS400.NET bridges your Web site gaps.
Use Ektron CMS400.NET for:
- Content & Document Management - Author/edit content, manage navigation, menus, audit trails, workflow, approvals
- Personalization & Portal Support - Allow visitors to create their own view of your web page
- 508 & W3C Compliance Checker - Ensure compliance with scheduled or on-demand compliance reports
- Memberships - Build online communties with blogs and forums, enable email web alerts, build polls and surveys
- Web Site Analytics - track visitors, report on most requested pages, see where they came from and where they are going
- HTML Form Engine - Create a two-way dialog with visitors using our wizard-like HTML form-building engine with validation and database support
- Multilingual Support - Integrated translation tools help you reach multiple audiences by speaking their language
- Online Calendars - Build and manage Web-based calendars and enable users to customize a view based on what’s important to them
See why there are 15,000+ Ektron integrations worldwide.
Click here to learn more, then request a live online demo or download a FREE TRIAL
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of
HTML, XHTML, and CSS.
The ASP Certificate is for developers who want to document their knowledge of
ASP, SQL, and ADO.
|
|