Xquery找到最后一项
使用XML类似:
<item >
<datapoint>5</datapoint>
</item>
<item >
<datapoint>4</datapoint>
</item>
<item >
<datapoint>6</datapoint>
</item>
<item >
<datapoint>8</datapoint>
</item>
<item >
<datapoint>9</datapoint>
</item>
项目的数量不是固定的数字。我已经在检索最后一个()数据点,但是现在我还需要抓住下一个数据点。因此,在此示例中,我需要单独返回8和9。
with xml something like:
<item >
<datapoint>5</datapoint>
</item>
<item >
<datapoint>4</datapoint>
</item>
<item >
<datapoint>6</datapoint>
</item>
<item >
<datapoint>8</datapoint>
</item>
<item >
<datapoint>9</datapoint>
</item>
And the number of items is not a fixed number. I am already retrieving the last() data point, however I now also need to grab the next to last data point. So in this example I need to separately return both the 8 and the 9.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此Xquery应该有效:
或者,您也可以使用一个较短的版本:
输出为:
This XQuery should work:
Or, you could also use a shorter version:
Output is:
首先,您的XML应该是良好的。这就是为什么我添加了一个root元素
xml
xquery
输出
First, your XML should be well-formed. That's why I added a root element
XML
XQuery
Output