3 Replies Latest reply on Jan 14, 2009 8:21 PM by rtalton

    XML Class behavior in Flex vs Flex/AIR

    gim010
      Hi, I created a small non-AIR application which simply wraps the text value of a TextArea into some XML tags using the XML Class (and the "escape()" function) as shown in the code attached (see "non-AIR application").

      The resulting XML is as follows (when viewed in the debugger and logged by the PHP script):
      <list>
      <item>...text value from TextArea...</item>
      </list>

      In my real application, I'm then sending this via an HTTPService to a PHP script on my server. The PHP script receives the XML in its entirety, no problem.

      When I wrote an equivalent (same code) AIR application (see "AIR application" in the attached code), the formatted XML becomes (when viewed in the debugger and logged by the PHP script):
      <list>
      &lt;item&gt;...text value from TextArea...&lt;/item&gt;
      </list>

      When sending this through the HTTPService, the parent <list> tag is removed, which causes the PHP script to fail.

      Is it normal behavior and is there a way around that? I looked in the forums but could not find any reference to this odd behavior change between AIR and non-AIR Flex.

      Anybody else experiencing the same issue?

      Thanks,

      Marc

        • 1. Re: XML Class behavior in Flex vs Flex/AIR
          rtalton Level 4
          Just a guess, but something's going on with your escape function. Step through it in Debug mode and see what's happening.
          • 2. Re: XML Class behavior in Flex vs Flex/AIR
            gim010 Level 1
            Hi rtalton and thanks for the thoughts. That made me thinking about how the XML class constructor and the appendChild methods should be called and found the issue.

            It seems that calling the "appendChild" method under AIR produces a different result than when not under AIR, which is curious in itself.

            However, I changed my code to be "proper" according to the documentation and it worked under both AIR and non-AIR. Here's what I changed:

            The appendChild method is now called as follows:

            list.appendChild(<item>{escape(taText.text)}</item>);

            The quotes were removed and I'm no longer treating the XML as a string.

            As well, while I was at it, I changed the call to the constructor as follows:

            list = new XML(<list></list>);

            Same thing here, no longer treating the XML as a string.

            Thanks,

            Marc
            • 3. Re: XML Class behavior in Flex vs Flex/AIR
              rtalton Level 4
              Great, glad you caught it. I hadn't noticed the quotes, but you're right on about them.