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.
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.
Kernow works well. Copy your XML document into the Kernow root folder and execute your queries in the "XQuery Sandbox".
精彩评论