请帮助我理解这个 XPath [英] Please help me on understanding this XPath
问题描述
我在我的一个学习代码中遇到了这个 XPath:
I came across this XPath in one of my studying code:
count($recprv//*[local-name()='provider_email' or local-name()='provider_fax'
or local-name()='provider_phone' or local-name()='provider_phone_ext' ])
我现在很难弄清楚它的意思,我个人认为它说:在 xml 文件 recprv 中,计算包含 provider_email 或包含 provider_fax 或包含 provider_phone 或包含 provider_phone_ext 的任何元素的数量.
I am now having a hard time figuring out what it means, I personally think it says:" in the xml file recprv, count the number of any elements that contain either provider_email or contains provider_fax or contains provider_phone or contains provider_phone_ext.
所以它基本上会遍历xml文件recprc并统计所有记录?只是有点糊涂.此外,我很想知道在 count 函数中究竟计算了什么.非常感谢你在这里帮助我!
So it will basically go through the xml file recprc and count all of the records? Just a bit confused. Moreover, I would love to know what is EXACTLY being counted in the count function. Thanks a lot for helping me out here!
推荐答案
count($recprv//*
[local-name()='provider_email'
or
local-name()='provider_fax'
or
local-name()='provider_phone'
or
local-name()='provider_phone_ext'
]
)
这意味着:
给我变量中包含的任何树中包含的所有元素的计数 $recprv
, whose local-name()(部分命名空间前缀后面的名称(如果存在,否则为全名)是provider_email
、provider_fax
、provider_phone之一代码> 或
provider_phone_ext
.
变量 $recprv
应该包含一个或多个元素(节点集),并且每个这样的元素都是基于父 --> 子关系的树的顶部.
The variable $recprv
should contain one or more elements (node-set) and every such element is the top of a tree based on the parent --> children relation.
这篇关于请帮助我理解这个 XPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!