[XML] Counting items and ignoring duplicate items

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.