I want to use xpath to count occurances of certain node in xml document. What would I use? For ex: If I wanted to get second occurance of movie
node I'd use movie[2]
.
How do I get total number of movie node occurances in document?
I want to use xpath to count occurances of certain node in xml document. What would I use? For ex: If I wanted to get second occurance of movie
node I'd use movie[2]
.
How do I get total number of movie node occurances in document?
Try count(//movie)
. See http://msdn.microsoft.com/en-us/library/ms256103.aspx for detail.
I want to use xpath to count occurances of certain node in xml document
Use count
function. From http://www.w3.org/TR/xpath/#function-count
The count function returns the number of nodes in the argument node-set
So, in your case, this XPath expression:
count(//movie)