YouTip LogoYouTip

Xquery Flwor Html

# XQuery FLWOR + HTML * * * ## XML Example Document We will continue to use this "books.xml" document in the following examples (same file as in the previous section). [View the "books.xml" file in your browser](#). * * * ## Presenting Results 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 above expression selects all title elements under the book elements under the bookstore element and returns the title elements in alphabetical order. Now, we want to list all the book titles in our bookstore using an HTML list. We add
    and
  • tags to the FLWOR expression:
      { for $x in doc("books.xml")/bookstore/book/title order by $x return
    • {$x}
    • }
    The above code outputs:
    • Everyday Italian
    • Harry Potter
    • Learning XML
    • XQuery Kick Start
    Now we want to remove the title element and only display the data inside the title element.
      { for $x in doc("books.xml")/bookstore/book/title order by $x return
    • {data($Geek Time Cashbackx)}
    • }
    The result will be an HTML list:
    • Everyday Italian
    • Harry Potter
    • Learning XML
    • XQuery Kick Start
← Xquery TermsXquery Flwor β†’