Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XML名称空间的Google表单XPath查询_Xml_Xpath_Google Sheets_Xquery - Fatal编程技术网

XML名称空间的Google表单XPath查询

XML名称空间的Google表单XPath查询,xml,xpath,google-sheets,xquery,Xml,Xpath,Google Sheets,Xquery,在下面的示例中,我试图检索date元素的最后一个和倒数第二个条目: <c:classroom>Classroom 1</c:classroom> <a:date>2018-03-01</a:date> <a:teacher>Ms Smith</a:teacher> <a:assistant>Sara</a:assistant> <a:student>Rose

在下面的示例中,我试图检索
date
元素的最后一个和倒数第二个条目:

<c:classroom>Classroom 1</c:classroom>
    <a:date>2018-03-01</a:date>
    <a:teacher>Ms Smith</a:teacher>
    <a:assistant>Sara</a:assistant>
    <a:student>Rose</a:student>
    <a:student>Kris</a:student>
    <a:student>Jane</a:student>
<c:classroom>Classroom 2</c:classroom>
    <a:date>2018-03-02</a:date>
    <a:teacher>Mr Jones</a:teacher>
    <a:assistant>Bob</a:assistant>
    <a:student>Mike</a:student>
    <a:student>Pat</a:student>
    <a:student>Rick</a:student>
<c:classroom>Classroom 1</c:classroom>
    <a:date>2018-03-05</a:date>
    <a:teacher>Ms Smith</a:teacher>
    <a:assistant>Sara</a:assistant>
    <a:student>Rose</a:student>
    <a:student>Kris</a:student>
    <a:student>Jane</a:student>
<c:classroom>Classroom 2</c:classroom>
    <a:date>2018-03-06</a:date>
    <a:teacher>Mr Jones</a:teacher>
    <a:assistant>Bob</a:assistant>
    <a:student>Mike</a:student>
    <a:student>Pat</a:student>
    <a:student>Rick</a:student>
教室1
2018-03-01
史密斯女士
萨拉人
玫瑰
克里斯
简
教室2
2018-03-02
琼斯先生
上下快速移动
迈克
拍打
瑞克
第一教室
2018-03-05
史密斯女士
萨拉人
玫瑰
克里斯
简
教室2
2018-03-06
琼斯先生
上下快速移动
迈克
拍打
瑞克
使用
/*[local-name()='date'][last()]
返回几乎所有内容,使用
/*[local-name()='date'][last()-1]
失败

有什么建议吗

更新:此XPath查询用于Google工作表。

尝试此XPath

(//*[local-name() = 'date'])[last() - position() &lt; 2]

这将获得文档中最后两个
日期。

谢谢。这个链接读起来很有趣。谢谢。这个问题实际上并不是重复的,因为参考文献(非常有用)已经过审查,Google Sheets不接受所有的XQuery;e、 g.Google Sheets似乎与
不兼容,尽管
通常的方法是
concat()
a

位于每个节点值的末尾。但我不知道谷歌的做法是什么。这个问题不应该重复,因为链接的参考文献(非常有用)已经过审查,而且谷歌表单不接受所有的XQuery。这最初是用标记的,并经过编辑以显式表示。此外,两个引用似乎都没有使用@zx485所使用的
last()
position()
运算符的组合。如果SE仍然认为它是重复的或没有足够的贡献独立,那么很高兴删除它。