2 Replies Latest reply on Jun 3, 2009 8:10 AM by Rajesh Subbiah

    First time in flex

    psbabupsbabu

      Hi,

                  I would like to learn flex. How to load this xml file using flex and display the same in the grid. Later I would like to remove the particulat row from the grid using the remove button. Please provide me with the code.

       

      -Thnks

        • 1. Re: First time in flex
          psbabupsbabu Level 1

          This is the XML file

           

           

          <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

           

           

           

                  <country name="China" competitors="10" total="30" events="15">
                      <medal category="Gold" count="51"/>
                      <medal category="Silver" count="28"/>
                      <medal category="Bronze" count="21"/>
                  </country>
                  <country name="USA" competitors="14" total="33" events="25">
                      <medal category="Gold" count="36"/>
                      <medal category="Silver" count="36"/>
                      <medal category="Bronze" count="38"/>
                  </country>
                  <country name="Russia" competitors="11" total="20" events="12">
                      <medal category="Gold" count="23"/>
                      <medal category="Silver" count="28"/>
                      <medal category="Bronze" count="21"/>
                  </country>
                  <country name="Great Britian" competitors="16" total="34" events="18">
                      <medal category="Gold" count="19"/>
                      <medal category="Silver" count="15"/>
                      <medal category="Bronze" count="13"/>
                  </country>
                  <country name="Germany" competitors="8" total="16" events="5">
                      <medal category="Gold" count="16"/>
                      <medal category="Silver" count="15"/>
                      <medal category="Bronze" count="10"/>   
                  </country>
                  <country name="Australia" competitors="30" total="50" events="35">
                      <medal category="Gold" count="14"/>
                      <medal category="Silver" count="17"/>
                      <medal category="Bronze" count="15"/>
                  </country>
                  <country name="South Korea" competitors="33" total="32" events="21">
                      <medal category="Gold" count="13"/>
                      <medal category="Silver" count="8"/>
                      <medal category="Bronze" count="10"/>
                  </country>
                  <country name="Japan" competitors="12" total="35" events="12">
                      <medal category="Gold" count="9"/>
                      <medal category="Bronze" count="6"/>
                      <medal category="Silver" count="10"/>
                  </country>
                  <country name="Italy" competitors="8" total="23" events="15">
                      <medal category="Gold" count="8"/>
                      <medal category="Silver" count="10"/>
                      <medal category="Bronze" count="10"/>  
                  </country>
                  <country name="Ukraine" competitors="10" total="30" events="17">
                      <medal category="Gold" count="7"/>
                      <medal category="Silver" count="17"/>
                      <medal category="Bronze" count="15"/>
                  </country>
                   <country name="Netherlands" competitors="5" total="23" events="22">
                      <medal category="Gold" count="7"/>
                      <medal category="Silver" count="4"/>
                      <medal category="Bronze" count="5"/>
                  </country>

          • 2. Re: First time in flex
            Rajesh Subbiah Level 1

            Hi psbabupsbabu,

             

            You want to access the xml. There three ways to access the server side data

            1.HttpService

            2.remote object

            3.Accessing web service.

             

            Let me tell you how to access using the HttpService.

             

            Do display the xml in data grid the data should not be hierarchical

            in data grid what result you want to display.

             

            Country | Gold | Sliver | Bronze

             

            If you are going to display this in grid then your xml must be like this

             

             

            <root>

                 <sample>

                 <country>India</country>

                 <gold>1</gold>

                 <sliver>23</sliver>

                 <bronze>2</bronze>

                 </sample>

                 <sample>

                 <country>china</country>

                 <gold>1</gold>

                 <sliver>23</sliver>

                 <bronze>2</bronze>

                 </sample>

               etc

             

            This is the way to store in database also you access these in data grid like this

             

                 <mx:HTTPService id="srv"  url="xml file path"/>

             

              <mx:DataGrid  dataProvider="{srv.lastResult.root.sample}" width="100%" height="100%"/>

              this loads the data in datagrid

             

            Reply me if you have doubts.

             

            Rajesh Subbiah