# Variable representing childnode length

**URL:** <https://forum.kirupa.com/t/variable-representing-childnode-length/189895>\
**Category:** Uncategorized\
**Created:** [June 7, 2006, 1:48am UTC](https://forum.kirupa.com/t/variable-representing-childnode-length/189895 "2006-06-07T01:48:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlowRoasted](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SlowRoasted](https://forum.kirupa.com/u/SlowRoasted)\
**Post date:** [June 7, 2006, 1:48am UTC](https://forum.kirupa.com/t/variable-representing-childnode-length/189895/1 "2006-06-07T01:48:08Z")

</div>

Okay I’m trying to make a variable inside of an xml onLoad function. I want the variable to be a number representing the length of firstchild.childnodes. This doesn’t seem to be working. Check out my code.

```auto

//Start xml onLoad function
inXML.onLoad = function() {
	
  var len:Number = inXML.firstChild.childNodes.length;

  for (i=0;i<this.firstChild.childNodes.length;i++) {
	  
	//Populate arrays with xml data
	src.push("images/"+ this.firstChild.childNodes*.firstChild.firstChild);
    //titles.push(this.firstChild.childNodes*.firstChild.nextSibling.firstChild);
    //desc.push(this.firstChild.childNodes*.firstChild.nextSibling.nextSibling.firstChild);
	//link.push(this.firstChild.childNodes*.firstChild.nextSibling.nextSibling.nextSibling.firstChild);
	
    //Attach picture holders from library
    attachMovie("picx","p"+i, i);
	
	//Set attributes for each image
    with(eval("p"+i)){
	  holder.loadMovie("images/"+ this.firstChild.childNodes*.firstChild.firstChild);
      _x = (i/3)*450-150;
	}
	
  }
  
  eval("p"+(picnum-1))._alpha = 60;
  eval("p"+(picnum+1))._alpha = 60;

}

```

```auto

<?xml version='1.0' encoding='iso-8859-1'?>

<pics>

  <pic>
    <src>1.gif</src>
    <titles>Cold Coffee America</titles>
    <desc>Flash contact form for Cold Coffee America.</desc>
    <link>http://www.coldcoffeeamerica.com</link>
    <tech>
      <t>Flash 8</t>
    </tech>
  </pic>

  <pic>
    <src>2.gif</src>
    <titles>National Freelance Directory</titles>
    <desc>PHP/MySQL backend for National Freelance Directory.</desc>
    <link>http://www.worldslargestforum.com/freelance</link>
    <tech>
      <t>PHP</t>
      <t>MySQL</t>
      <t>CSS</t>
    </tech>
  </pic>
  
  <pic>
    <src>3.gif</src>
    <titles>National Freelance Directory</titles>
    <desc>PHP/MySQL backend for National Freelance Directory.</desc>
    <link>http://www.worldslargestforum.com/freelance</link>
    <tech>
      <t>PHP</t>
      <t>MySQL</t>
      <t>CSS</t>
    </tech>
  </pic>
  
  <pic>
    <src>4.gif</src>
    <titles>National Freelance Directory</titles>
    <desc>PHP/MySQL backend for National Freelance Directory.</desc>
    <link>http://www.worldslargestforum.com/freelance</link>
    <tech>
      <t>PHP</t>
      <t>MySQL</t>
      <t>CSS</t>
    </tech>
  </pic>
  
  <pic>
    <src>5.gif</src>
    <titles>National Freelance Directory</titles>
    <desc>PHP/MySQL backend for National Freelance Directory.</desc>
    <link>http://www.worldslargestforum.com/freelance</link>
    <tech>
      <t>PHP</t>
      <t>MySQL</t>
      <t>CSS</t>
    </tech>
  </pic>

```
