2 Replies Latest reply on Jul 6, 2009 10:49 AM by Jerry62712

    XML processing

    Jerry62712 Level 1

      I was able to get the input stream from the queryString to the application I'm working with.  For example, if you called the application with this:

       

      FSCalc.html?xml=<?xml version="1.0" encoding="UTF-8" ?><FSParm><HouseholdSize>6</HouseholdSize><GrossMonthlyEarnedIncome>2000</GrossMonthlyEar nedIncome>
      </FSParm>

       

      the contents of the string of the input is this:

       

      inputString=<?xml version="1.0" encoding="UTF-8" ?><FSParm><HouseholdSize>6</HouseholdSize><GrossMonthlyEarnedIncome>2000</GrossMonthlyEar nedIncome></FSParm>

       

      I then take that string and put it in an XMLList.

      private var parseXML:XMLList = inputString;

       

      What I need to know now is how to get the key name and value pairs in an actionscript.  In pseudo code it would look like this:

       

                 for each(item in parseXML) {
                    if (item key = "xyz") {

                       setXYZ(item value) }

                    if (item key = "abc" {

                       setABC(item value) }
                 }

       

      How can I make this happen?

        • 1. Re: XML processing
          Flex harUI Adobe Employee

          I don't trust auto-conversion in AS3 (it works reliably, I just cannot remember the rules).

           

          So, I think you started with a string that was the full url, and found a way to find a substring that was the right hand side of xml=.

           

          If inputString a string, that should be converted to XML (not XMLList) via

           

          Var fsParm:XML = new XML(inputString);

           

          And its pieces will then be available as:

           

          fsParm.HouseholdSize

          fsParm.GrossMontlyEarnedIncome

           

          fsParm.HouseholdSize is an XMLList so to get a number you have to do

           

          var householdSize:int = int(fsParm.HouseholdSize[0].toString())

          or if you know there'll only be one entry in the list,

          var householdSize:int = int(fsParm.HouseholdSize.toString())

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: XML processing
            Jerry62712 Level 1

            Thank you.  I have another problem that I'll start a new thead with (to not pollute this one).