12 Replies Latest reply on Feb 4, 2011 7:40 AM by Pablo Souza

    Flex and XML

    mssrivatsa

      Hi

       

      I am working on a web app in flex 4 that has to access remote XML file to display data in a datagrid. The remote XML file is in Red Hat Linux server. I need help in the following two areas.

       

      1. How to access this XML file?

      2.Once the XML data is accessed, the datagrid has to refresh as and when the XML file( remote ) contents are changed. How?

       

      Thanks in Advance!!

      M.S.Srivatsa

        • 1. Re: Flex and XML
          learner_doug Level 1

          I can only tell you how to access the XML file and pull into Flex, but I never used the Datagrid with XML (only SQL).

           

          Here is a simple example of putting XML data into a dropDown. 

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Group

           

           

          xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="

          library://ns.adobe.com/flex/spark"

          xmlns:mx="

          library://ns.adobe.com/flex/mx" width="400" height="300" creationComplete="dropDownListXML.send()">

           

           

          <fx:Declarations>

           

           

          <!-- Place non-visual elements (e.g., services, value objects) here -->

           

           

          <s:HTTPService id="dropDownListXML" url="EBSnewMileStones.xml" />

           

           

          </fx:Declarations>

           

           

          <s:ComboBox id="msDropDown"

          dataProvider="

          {dropDownListXML.lastResult.milestones.milestone}"

          x="

          10" y="10" width="240"

          chromeColor="

          #CCCCCC" color="#000000"

          labelField="

          name"/>

          </s:Group>

           

          Sorry I couldn't be of more help.  I do know that th datagrid has an option when you right-click it to "Bind to Data" - perhaps that will help.

          • 2. Re: Flex and XML
            miguel8312 Level 3

            There are several ways to access the xml

            remote access

            webservices

            httpservice

            you must decide which are going to use to have the server talk to you flex client app.

            Once you decide that then you can get access to the  xml  using a varierty of techiques again you have to decide whether you are going to use "E4X" or "object" the decision you make here is somewhat dependent on what you are comfortable with and what type of service you will be using.

            if you would want you app to automatically update when the xml changes then you are going to want to use "AMF" however i fyou don want to get into "AMF" then it is my experience you can simulate looking back at the server by simply putting a timer on the application and have run every 30 seconds or so dependent on what you like.

            Post up if you have any other questions.

            here is a link to help you get started.

            http://livedocs.adobe.com/flex/3/html/help.html?content=data_intro_2.html

            1 person found this helpful
            • 3. Re: Flex and XML
              Flex harUI Adobe Employee

              It will probably require a combination of HTTPService, XMLListCollection and

              DataGrid.

              • 4. Re: Flex and XML
                learner_doug Level 1

                The major problem I might have with a datagrid, is that my application needs to look like the attached.

                 

                Thanks,

                Doug

                • 5. Re: Flex and XML
                  learner_doug Level 1

                  Yea, I'm thinking I may move this to the DataGrid.

                  Thanks!

                  • 6. Re: Flex and XML
                    learner_doug Level 1

                    OK -thanks for all the information (AMF sounds interesting).  One last question:  Regardless of the method I use to bring in XML, can the XML items populate TextArea text and tooltip properties?  Is it possible?  (I'll read the articles and docs to find out how if it is possible )

                    • 7. Re: Flex and XML
                      learner_doug Level 1

                      FYI:  In case you are curious - The attached is an example of the Captivate movie that launches from the application (hundreds of these) - you helped me to get this to work quite well. 

                       

                      Thanks again.

                      • 8. Re: Flex and XML
                        miguel8312 Level 3

                        One last question:  Regardless of the method I use to bring in XML, can the XML items populate TextArea text and tooltip properties?  Is it possible?

                         

                        yes its possible to populate the text area with xml  however im not sure about tooltip thought i would like to say yes i never done this.

                        however i couldnt see why not.

                         

                         

                        miguel

                        • 9. Re: Flex and XML
                          mssrivatsa Level 1

                          Thanks Guys,

                           

                          But in my case the data access methods are redundant in the sense I already have a ready made XML file and these data access methods such as HTTPService process and finally return XML (in my case its already present). So is there any way to refresh datagrid after a particular time if I bind it with XML service??

                           

                          M.S.Srivatsa

                          • 10. Re: Flex and XML
                            learner_doug Level 1

                            Thank you.

                            • 11. Re: Flex and XML
                              learner_doug Level 1

                              I do not know.  Sorry 'bout that.

                              • 12. Re: Flex and XML
                                Pablo Souza Level 3

                                Hi M.S.Srivatsa,

                                 

                                There is no way to do that directly through the XML service.

                                You can implement a Timer to call this service after a period of time.

                                 

                                 

                                Regards,

                                Pablo Souza