W3Schools

home HOME

XQuery Basic
XQuery HOME
XQuery Intro
XQuery Example
XQuery FLWOR
XQuery HTML
XQuery Terms
XQuery Syntax

XQuery Advanced
XQuery Add
XQuery Select
XQuery Functions
XQuery Summary

XQuery Reference
XQuery Reference

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

pixels

XQuery FLWOR + HTML

previous next

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>


previous next


What do you want your Web site to do?

Ektron

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 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




diploma   

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.


Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2007 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
SITE SEARCH
 
About W3Schools
W3Schools Forum
ASPHits
Active Server Pages Resource Web Site
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
UK Domain Names
UK Web Hosting

Alojamiento Web
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
Domain Name Registration
UK Web Hosting
PHP MySQL Hosting
Web Hosting UK
Top 10 Web Hosting
Web Hosting Providers
ASP.NET Web Hosting
Programming Forums
Windows Web Hosting
WEB BUILDING
XML Website Tools
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
BEST Flash Templates
Web Design Forum
Programming Forum
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
HTML Exam
SHOPPING
UK Wholesalers
UK Wholesale
ONLINE DEGREE
Advance Your Career
with Drexel University
Bachelor's & Master's
Tech Degrees ONLINE
YELLOW PAGES
www.nettkatalogen.no
www.gulex.no
www.gulex.se

pixels