...

View Full Version : Counting children



TNO
11-13-2008, 10:54 PM
What would the xpath expression be to find the element with the most children?

Counting is simple, removing duplicates is simple..but this one escapes me, any ideas?

TNO
11-17-2008, 03:28 PM
Ok, here's the answer on finding an element with the most immediate children:


//parent[count(children) >= count(following::parent/children)]/children

You want to look at the following instead of the preceding so you don't get false positives.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum