., 在 XPath 中有什么用? [英] What is the use of ., in XPath?

查看:34
本文介绍了., 在 XPath 中有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在某些 XPath 表达式中的句点后使用逗号?下面是一个例子:

Set nlist = doc.selectNodes("//book/author/first-name[starts-with(.,'M')]")

我尝试用 Google 搜索此内容,但文字 "" 运算符似乎不喜欢句点或逗号.

解决方案

在 XPath 中,. 标记代表 context node.上下文节点通常与正在处理的当前节点(current()函数)相同,但也可能是不同的情况.当您只处理 XPath 时,这并不是很明显,但在使用 XSLT 时会发生.请参阅此问题,以解释这种差异.>

Why is a comma used after the period in certain XPath expressions? Here is an example:

Set nlist = doc.selectNodes("//book/author/first-name[starts-with(.,'M')]")

I tried to search for this with Google, but the literal "" operators don't seem to like periods or commas.

解决方案

In XPath the . mark stands for context node. The context node is usually the same of the current node (current() function) being processed but it might be situations where it's different. This is not really obvious when you deal with XPath only, but it happens when using XSLT. See this question in SO explaining such a difference.

这篇关于., 在 XPath 中有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆