6 Replies Latest reply on Mar 5, 2009 2:05 PM by Ned Murphy

    Problem with updating XML node count

    timmydenty
      In my Flash movie I'm trying to navigate through a selection of clients stored in XML. Each client has a different number of projects.

      When I click a button which alters the value of [n] to switch to a different node(client), the number of subnodes(projects) never changes - it simply counts from the last node in the xml file (2 in the example below).

      How can I make this change each time a different client node is selelcted?

      Any ideas?

      AS:
      total = xmlNode.childNodes.length; // No. of clients

      for (n=0; n<total; n++) {
      name [n] = xmlNode.childNodes[n].childNodes[0].firstChild.nodeValue;
      picture [n] = new Array();
      description [n] = new Array();

      subtotal = xmlNode.childNodes[n].childNodes.length; // No. of projects

      for (i=0; i<subtotal; i++) {
      picture [n]
      = xmlNode.childNodes[n].childNodes .childNodes[0].firstChild.nodeValue;
      description [n]
      = xmlNode.childNodes[n].childNodes .childNodes[1].firstChild.nodeValue;
      }
      }

      XML:
      <data>
      <client>
      <name>Name 1</name>
      <project>
      <image>images/1a.gif</image>
      <description>Description for project 1a appears here</description>
      </project>
      </client>
      <client>
      <name>Name 2</name>
      <project>
      <image>images/2a.jpg</image>
      <description>Description for project 2a appears here</description>
      </project>
      <project>
      <image>images/2b.jpg</image>
      <description>Description for project 2b appears here</description>
      </project>
      </client>
      </data>