So, we have a XUL component, that looks like this:

<listbox id="listboxId">
<listitem label="1" />
<listitem label="2" />
<listitem label="3" />
</listbox>

We can loop through the elements of this componenet using XPCOM:

var lbox = document.getElementById(‘listboxId’);

for (var i =0; i<lbox.children.length; i++)
{
var child = lbox.children[i];
//do someting with child, like
alert(child.label)
}