13 Replies Latest reply on Aug 24, 2008 3:57 PM by kglad

    XML question

    ibrubru
      i have the following code in the xml file:
      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <images>
      <pic>
      <image>images/image1.jpg</image>
      <caption> caption1 here </caption>
      </pic>
      <pic>
      <image>images/image2.jpg</image>
      <caption> caption2 here </caption>
      </pic>
      </images>

      in flash i can extract the xml data by the following code:
      function loadXML(loaded) {
      if (loaded) {
      xmlNode = this.firstChild;
      image = [];
      description = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
      image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
      description = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
      }
      } else {
      content = "file not loaded!";
      }
      }

      If I need to have caption1 to match 4 images, how do I construct the xml? Please help.
      I have tried the followings: (not working)

      <images>
      <pic>
      <subimages>
      <image>images/imageA1.jpg</image>
      <image>images/imageA2.jpg</image>
      <image>images/imageA3.jpg</image>
      <image>images/imageA4.jpg</image>
      </subimages>
      <caption> caption1 </caption>
      </pic>
      <subimages>
      <image>images/imageB1.jpg</image>
      <image>images/imageB2.jpg</image>
      </subimages>
      <caption> caption2 </caption>
      </pic>
      <images>


      xmlNode = this.firstChild;
      image = [];
      subimage = [];
      description = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
      subimage = xmlNode.childNodes.childNodes[0].childNotes .firstChild.nodeValue;
      description
      = xmlNode.childNodes .childNodes[1].firstChild.nodeValue;