AAsk
AAsk

Reputation: 1491

Adding Elements and Attributes in XQuery

Using the code from this W3Schools sample:

<html>
    <body>

        <h1>Bookstore</h1>

        <ul>
        {
           for $x in doc("books.xml")/bookstore/book
           order by $x/title
           return <li>{data($x/title)}. Category: {data($x/@category)}</li>
        }
        </ul>

    </body>
</html>

I saved it to test.html & opened it in a browser. All I see is the code rather than the result.

I am obviously missing something; how do I see the results?

Thanks.

Upvotes: 0

Views: 530

Answers (2)

Rose Perrone
Rose Perrone

Reputation: 63546

Kernow works well. Copy your XML document into the Kernow root folder and execute your queries in the "XQuery Sandbox".

Upvotes: 0

Daniel Haley
Daniel Haley

Reputation: 52858

I would recommend getting an XQuery processor such as Saxon. You can use this along with the books.xml sample and the XQuery sample to produce an HTML file to view in the browser. (Saxon-HE is free and is an excellent (the best?) processor.)

For XQuery directly in a browser (IE only for now I think), take a look at XQIB – XQuery In the Browser.

I would definitely stick with Saxon while you're just learning XQuery. What would be perfect to help you write/test XQuery while you learn it is oXygen Editor. They have different pricing options and is worth every dime.

Upvotes: 1

Related Questions