Documentation Center

getChildNodes

Description

Get the collection of child nodes of this node.

Usage

This method does not return an array, but an XopusNodeList. This list can be iterated over in a somewhat similar manner though, and can be used to manipulate the children of an element.

<xsl:template match="myoddlynumberedlist">
   <div>    
    <xsl:apply-templates select="oddlynumberedchild"/>
    <div>
      <button onclick="addOddlyNumberedChild(node)">add</button>
    </div>   
  </div> 
</template>
function addOddlyNumberedChild(xopusElement) 
{ 
  var doc = xopusElement.getOwnerDocument();

  var newEl = doc.createElement("oddlynumberedchild");
  xopusElement.appendChild(newEl);
  
  //renumber the children
  for(var i = 0; i < xopusElement.getChildNodes().getLength();i++)
  {
     var oddChild = xopusElement.getChildNodes().item(i); 
     
     var oddNumber = Math.round(Math.random()*xopusElement.getChildNodes().getLength());
     
     oddChild.setAttribute("number",oddNumber);
   } 
}

Syntax

XopusNode .getChildNodes () : XopusNodeList

Return Value

XopusNodeList . The child nodes.