# \[XML\] Counting items and ignoring duplicate items

**URL:** <https://forum.kirupa.com/t/xml-counting-items-and-ignoring-duplicate-items/195448>\
**Category:** programming\
**Created:** [July 31, 2006, 9:39pm UTC](https://forum.kirupa.com/t/xml-counting-items-and-ignoring-duplicate-items/195448 "2006-07-31T21:39:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thalamus](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thalamus](https://forum.kirupa.com/u/thalamus)\
**Post date:** [July 31, 2006, 9:39pm UTC](https://forum.kirupa.com/t/xml-counting-items-and-ignoring-duplicate-items/195448/1 "2006-07-31T21:39:40Z")

</div>

Hello:

Based on senocular’s “Squirrel Finder” XML tutorial, I am trying to create and populate a menu of buttons of artist’s names from an XML file containing a list of art pieces and their information. Some items will have duplicate artist names or node attributes, i.e., artists may have more than one piece in the collection.

My XML structure looks similar to this:

\<inventory\>  
\<item type=“ceramic” title=“Ceramic piece 1” artistname="[COLOR=seagreen]Joe[/COLOR]" /\>  
\<item type=“glass” title=“Glass piece 1” artistname=“Bob” /\>  
\<item type=“sculpture” title=“Sculpture 1” artistname="[COLOR=seagreen]Joe[/COLOR]" /\>  
\</inventory\>

using AS to search under the “artistname” attribute  
so the menu looks like this when populated:

[COLOR=royalblue]Joe[/COLOR] (2)  
[COLOR=royalblue]Bob[/COLOR] (1)

or

[COLOR=#4169e1]Joe[/COLOR] (2)  
[COLOR=#4169e1]Bob[/COLOR]

To make an analogy to the squirrel finder, if \*n \*\<species\> nodes contain “Douglas Squirrels” I want one button to say “Douglas Squirrels (_n_)” rather than have _n_ buttons that say “Douglas Squirrels”.

What loops or coding do I need to add to the AS in the example to make this work?

Thanks.
