2 Replies Latest reply: Jun 8, 2010 12:37 AM by Kristtee RSS

    loading nested data in E4X way?

    Kristtee Community Member

      Hi there!

      I was able to get all the data but I don't know how to get the nestetd data into a listbox onselecting an item in a DataGrid. Here is my xml data. can someone help me please. Appreciate your time and help.

      Thank you

      Krish

      ----------------xml data-----------------

      <?xml version="1.0" encoding="utf-8"?>
      <myshop>
          <product>
              <name>Kindle Wireless Reader</name>
              <category>Electronic</category>
              <features>
                  <feature>Slim</feature>
                  <feature>Wireless</feature>
                  <feature>3G</feature>
                  <feature>Long Battery Life</feature>
              </features>
          </product>
          <product>
              <name>Digital Photography For The Web</name>
              <category>Book</category>
              <features>
                  <feature>Focus on the Web</feature>
                  <feature>Step by step lessons</feature>
                  <feature>Great advices</feature>
                  <feature>All Full Color Pictures</feature>
              </features>
          </product>
          <product>
              <name>Sigma 70-300mm f/4-5.6 DG Macro Telephoto Zoom Lens</name>
              <category>Lens</category>
              <features>
                  <feature>Reduces flare and ghosting</feature>
                  <feature>For portraits</feature>
                  <feature>Sports photography</feature>
                  <feature>Nature photography</feature>
              </features>
          </product>
      </myshop>

      -------------------------------------------------------

        • 1. Re: loading nested data in E4X way?
          FlashLeaner Community Member

          import flash.net.*;

          var req:URLRequest = new URLrequest("nameoffile.xml");

           

          var l:URLLoader = new URLLoader();

          var myXML:XML;

           

           

          l.load(req);

          l.addEventListener(Event.COMPLETE , loadComplete);

           

           

          function loadComplete(e:Event):void{

           

          myXML = XML(l.data);

           

          }

          • 2. Re: loading nested data in E4X way?
            Kristtee Community Member

            Hi here is my script.

            it loads the product data into my dg on the stage. now how do i make it clickable and on clicking it loades the features data into a listbox comp on the stage.

            please help me. appreciate your time,

            krish

            -----------------

            import fl.controls.dataGridClasses.DataGridColumn;
            import fl.controls.List;
            import fl.data.DataProvider;
            import flash.events.*;
            import flash.net.*;

             

            var ldr:URLLoader = new URLLoader();
            var xmlData:XML = new XML();
            ldr.addEventListener(Event.COMPLETE, ecHandler);
            ldr.load(new URLRequest("myshop.xml"));

             

            function ecHandler(e:Event):void{
                xmlData = new XML(e.target.data);
                var pcol:DataGridColumn = new DataGridColumn("name");
                pcol.headerText = "Product";
                var ccol:DataGridColumn = new DataGridColumn("category");
                ccol.headerText = "Category";
               
                var pdp:DataProvider = new DataProvider(xmlData);
                dg.columns = [pcol, ccol];
                dg.dataProvider = pdp;
            }

            ----------------------------