Please help me on understanding this 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' ])
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.
So it will basically go through the xml file recprc and c开发者_运维百科ount 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'
]
)
This means:
Give me the count of all elements that are contained in any of the trees contained in the variable $recprv
, whose local-name() (the part of the name following the namespace prefix, if such is present or the whole name otherwise) is one of provider_email
, provider_fax
, provider_phone
or provider_phone_ext
.
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.
$recprv is a variable so the XPATH is acting on the node-set contained in the variable
The local-name() function returns the part of the Element name with-out the namespace URI so for example they would match element names like <provider_phone />
as well as <xyz:provider_phone />
精彩评论