在 XQuery 中添加元素和属性

发布于 2024-11-07 18:40:49 字数 557 浏览 7 评论 0原文

使用此 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦中楼上月下 2024-11-14 18:40:49

我建议使用 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.

许一世地老天荒 2024-11-14 18:40:49

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文