Sample XML document:
<?xml version="1.0"?>
<names>
<name>abc</name>
<name>abc</name>
<name>xyz</name>
<name>def</name>
<name>ghi</name>
</names>
Output needed as:
abc: 2
xyz: 1
def: 1
ghi: 1
Tried the below XPath expression :-
for $n in //names/name return concat($n, ': ', count(//$n))
But output comes like this:
abc: 1
abc: 1
xyz: 1
def: 1
ghi: 1