xml - Xpath count function dosn't work -


i have following xml document :

 <root> <lockerentries>     <accountid>       <accountid>717</accountid>       <businessunit>usit</businessunit>     </accountid>     <policyid>ps_d8d</policyid>     <id>0x02a9c2a2e59145daff482</id>     <lastmodified>1448265403925</lastmodified>     <authorizationstart>1448265403453</authorizationstart>     <lockerentryevents>       <created>1483452726419</created>       <name>102</name>     </lockerentryevents>     <lockerentryevents>       <created>1483452726419</created>       <name>102</name>     </lockerentryevents>     <lockerentryevents>       <created>1483452726419</created>       <name>102</name>     </lockerentryevents>     <lockerentryevents>       <created>1483452726419</created>       <name>102</name>     </lockerentryevents>   </lockerentries> <lockerentries>     <accountid>       <accountid>71713470</accountid>       <businessunit>usit</businessunit>     </accountid>     <policyid>ps_010fe850</policyid>     <id>0x0000014fb321985cb7ad7e9cec19e79</id>     <lastmodified>1441820147278</lastmodified>     <authorizationstart>1441820145385</authorizationstart>     <lockerentryevents>       <created>23332345362</created>       <name>queued</name>     </lockerentryevents>   </lockerentries> </root> 

how write xpath expression select count of lockerentryevents under lockerentries , policyid=ps_d8d tried (//lockerentries[policyid="ps_d8d"]//count(//lockerentryevents)) doesn't work. should count=4 thank you

"how write xpath expression select count of lockerentryevents under lockerentries , policyid=ps_d8d"

this correct xpath :

count(//lockerentries[policyid='ps_d8d']/lockerentryevents) 

xpathtester demo

output :

4 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -