10 Replies Latest reply on Jun 28, 2008 8:27 AM by Whitetimer

    Text to XML

    Whitetimer
      Hi All

      Ok i'm trying to get started to a small utility, but need some advice/guidance. If i have a list like this

      quote:


      RacePitKPH = 82
      NormalPitKPH = 82
      Practice1Day = Friday
      Practice1Start = 10:00
      Practice1Duration = 90
      Practice2Day = Friday
      Practice2Start = 14:00
      Practice2Duration = 90
      Practice3Day = Saturday
      Practice3Start = 11:00
      Practice3Duration = 60
      Qualify1Day = Saturday
      Qualify1Start = 13:30
      QualifyDuration = 15
      QualifyLaps = 12
      RaceDay = Sunday
      RaceStart = 14:00
      RaceTime = 120
      RaceLaps = 58



      How could i convert this from a text file to an xml or array. I know its a noob question, but hopefully someone will point me in the right direction :)

      Many Thanks

      Shihan
        • 1. Re: Text to XML
          Gregory Lafrance Level 6
          This shows using an array of objects:
          • 2. Re: Text to XML
            Whitetimer Level 1
            Hi Greg

            Thanks for the advice, however the list is in an external text document that i have to import into the application edit changes and then export out.

            Kind regards

            Shihan
            • 3. Re: Text to XML
              ntsiii Level 3
              How are you getting it into Flex?
              Tracy
              • 4. Re: Text to XML
                Whitetimer Level 1
                quote:

                Originally posted by: ntsiii
                How are you getting it into Flex?
                Tracy


                Hi Tracy

                The file will either sit on the client or it can be on a server, but mainly this will be on a client. So will probably do

                quote:


                var file:File = new File();
                file.nativePath = "D:\\file.gdh\\";



                Regards

                Shihan
                • 5. Re: Text to XML
                  ntsiii Level 3
                  I don't do AIR yet, but if you are getting that file as a text sting, you will need to parse it yourself.

                  Tracy
                  • 6. Re: Text to XML
                    Whitetimer Level 1
                    Hi Tracy

                    I dont really do Air either, still getting my head around AS/Flex ... So what would you suggest if i did it through Flex as a Web App in the browser ... ?

                    Regards

                    Shihan
                    • 7. Re: Text to XML
                      Gregory Lafrance Level 6
                      The following shows how to read in an XML, dynamically create UI from the XML, and then change the XML. Its a somewhat contrived example, and I don't know how you would then upload the updated XML back to the server, but maybe Tracy can show us that :-).
                      • 8. Re: Text to XML
                        Whitetimer Level 1
                        quote:

                        Originally posted by: Greg Lafrance
                        The following shows how to read in an XML, dynamically create UI from the XML, and then change the XML. Its a somewhat contrived example, and I don't know how you would then upload the updated XML back to the server, but maybe Tracy can show us that :-).


                        Hi Greg

                        Thanks for the example, i'll take a look later. However the file is not an xml, but a normal text file as its part of a race sim application. So i'd need to convert it to XML Format make the changes and then convert back to original format before saving to its default location.

                        Many thanks

                        Shihan
                        • 9. Re: Text to XML
                          Gregory Lafrance Level 6
                          That's easy enough. Read in the text file, parse it, perhaps with regular expressions, do what you want then upload back to server. You might not even need to convert to XML.
                          • 10. Re: Text to XML
                            Whitetimer Level 1
                            quote:

                            Originally posted by: Greg Lafrance
                            That's easy enough. Read in the text file, parse it, perhaps with regular expressions, do what you want then upload back to server. You might not even need to convert to XML.


                            Thanks Greg ... I'm still very new at AS, so will have a look around for some examples !


                            Cheers

                            Shihan