【发布时间】:2020-12-16 16:14:34
【问题描述】:
$p 在哪里以及如何定义或创建from?为什么它根本是节点的索引或位置?
来自 w3schools 的输入,bookstore 示例。
输出:
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
查询:
xquery version "3.1";
let $doc := db:open("bookstore")
let $books := $doc/bookstore/book
for $book at $p in $books
where $p eq 2
return $book
是“at”为 $p 分配索引?然而,我的理解是 xpath 是声明性的而不是迭代的。然而,这至少类似于迭代。 “at”可能不是迭代,而只是该节点在该文档中的位置?
另见:
C# What query language to specify in rule to pull out the two book nodes
一个相关的问题。
【问题讨论】:
标签: xml xpath xquery basex flwor