# Count XML items (after pushed to array)

**URL:** <https://forum.kirupa.com/t/count-xml-items-after-pushed-to-array/283774>\
**Category:** flash\
**Created:** [March 10, 2009, 11:14pm UTC](https://forum.kirupa.com/t/count-xml-items-after-pushed-to-array/283774 "2009-03-10T23:14:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedromau](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pedromau/32/2793_2.png) [@pedromau](https://forum.kirupa.com/u/pedromau)\
**Post date:** [March 10, 2009, 11:14pm UTC](https://forum.kirupa.com/t/count-xml-items-after-pushed-to-array/283774/1 "2009-03-10T23:14:06Z")

</div>

Hello guys!  
I’m trying to figure out how to find the exact location of an XML item after I pushed it to an array…  
I’m using this to find the item with the “fotoNR” number:

```auto
currentPic = "1111";
for (var i:Number = 0; i<numimages; i++) {
 fotoNR = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
 data = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
 categoria = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
 miniatura = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
 imagem = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
 descricao = xmlNode.childNodes*.childNodes[5].firstChild.nodeValue;
 if(fotoNR == _root.currentPic){
  myarray2.push({
  fotoNR:fotoNR, data:data, categoria:categoria, miniatura:miniatura, imagem:imagem, descricao:descricao});
 }
}

```

This is working… I can see the item that corresponds to the **currentPic** var / **fotoNR** node.  
What I need to know is the location of it in the XML document!  
I mean, if my XML looks like this:

```auto
<foto>
  <fotoNR>112</fotoNR>
  <data>03.03.2009</data>
  <categoria>Misc</categoria>
  <miniatura>galerias/Misc/miniaturas/shoe.jpg</miniatura>
 <imagem>galerias/Misc/shoe.jpg</imagem>
  <descricao><![CDATA[Shoe]]></descricao>
</foto>
<foto>
  <fotoNR>1111</fotoNR>
  <data>03.03.2009</data>
  <categoria>BW</categoria>
  <miniatura>galerias/BW/miniaturas/ZL3.jpg</miniatura>
 <imagem>galerias/BW/ZL3.jpg</imagem>
  <descricao><![CDATA[Z&L III]]></descricao>
</foto>
<foto>
  <fotoNR>320</fotoNR>
  <data>01.03.2009</data>
  <categoria>Portraits</categoria>
  <miniatura>galerias/Portraits/miniaturas/ZL4.jpg</miniatura>
 <imagem>galerias/Portraits/ZL4.jpg</imagem>
  <descricao><![CDATA[Z&L II]]></descricao>
</foto>

```

the item with fotoNR 1111 is the second (2) one…  
But how do I find that by code?  
Basically, I need to know **how many items go from the beggining till the finded one**!
