在 XQuery 中添加元素和属性
使用此 W3Schools 示例中的代码:
<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>
我将其保存到 test.html &在浏览器中打开它。我看到的只是代码而不是结果。
我显然错过了一些东西;我如何查看结果?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用 XQuery 处理器,例如 Saxon。您可以将其与
books.xml
示例和 XQuery 示例一起使用来生成要在浏览器中查看的 HTML 文件。 (Saxon-HE 是免费的,并且是一个优秀的(最好的?)处理器。)对于直接在浏览器中的 XQuery(我认为目前仅限于 IE),请查看 XQIB – 浏览器中的 XQuery。
当您刚刚学习 XQuery 时,我肯定会坚持使用 Saxon。 oXygen Editor 是帮助您在学习 XQuery 时编写/测试 XQuery 的最佳选择。他们有不同的定价选择,而且物有所值。
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 效果很好。将 XML 文档复制到 Kernow 根文件夹中,并在“XQuery Sandbox”中执行查询。
Kernow works well. Copy your XML document into the Kernow root folder and execute your queries in the "XQuery Sandbox".