4 Replies Latest reply on Feb 3, 2011 1:58 AM by uteare

    Http and XML


      In my application I create an http service to retrieve data from an AS400 server. It works fine but when a field have one or more blank spaces before the string it seems that the spaces are trimmed. The response is like "<code>    apple</code>" but when I put the value into a text field I can see only "apple" and not "    apple"; if I have a response like "<code>lemon    </code>" in text field I can see "lemon    ".
      Is there anybody with the same problem that found the solution?


        • 1. Re: Http and XML
          learner_doug Level 1

          Never had this exact problem, but I might just add that the AS400 uses EBCDIC rather than ASCII which might be a place to start looking.  Sorry for lack of more specifics and I wish you well in your search. 

          • 2. Re: Http and XML
            uteare Level 1

            I think it's not important that data comes from AS400. I make a new application in which I read an XML file, this one:



            <code> pear</code>

            <code>apple </code>



            with HTTPService Spark tag and the result is the same, I can see blank spaces after apple but not blank spaces before pear. Looking at Network Monitor the Raw View give me this:


            HTTP/1.1 200 OK
            Date: Wed, 02 Feb 2011 16:15:33 GMT
            Server: Apache/2.0.64 (Win32)
            Last-Modified: Wed, 02 Feb 2011 15:50:53 GMT
            ETag: "32172-39-9d2b1f70"
            Accept-Ranges: bytes
            Content-Length: 57
            Content-Type: application/xml

            <root><code>  pere</code><code>mele  </code></root>


            as you can see there are blank spaces, when the result handler HTTPService function is run the result is that blank spaces before "pear" disappear not after "apple".

            The function is:


            var arrow:ArrayCollection = new ArrayCollection();


            protected function prova_resultHandler(event:ResultEvent):void


                 this.arrow = event.result.root.code;

                 firstcode = this.arrow[0];

                secondcode = this.arrow[1];





            • 3. Re: Http and XML
              learner_doug Level 1

              Yes, that was a bit of a long shot.  I wonder if the whitespace is the problem.  This is probably less of a long-shot, but


              when "ingoreWhitespace" is true, it removes beginning and ending white space from text nodes.

              • 4. Re: Http and XML
                uteare Level 1

                Yes, the whitespaces is the problem. We want to preserve whitespaces before and after any value.

                I change my example application; here is the code:



                <?xml version="1.0" encoding="utf-8"?>
                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      minWidth="955" minHeight="600">
                   import mx.events.FlexEvent;
                   import mx.rpc.events.ResultEvent;
                   import spark.events.IndexChangeEvent;

                   private var myURLservice:URLLoader = new URLLoader();
                   private var myURL:URLRequest = new URLRequest("http://localhost/flex/example/provadati.xml");
                   [Bindable]private var XMLdati:XMLList;

                   protected function resultExample_resultHandler(event:ResultEvent):void
                    XML.ignoreWhitespace = false;
                    XMLdati = new XMLList(event.result.root.code);
                    firstcode.text = this.XMLdati.toString();
                   private function application1_creationCompleteHandler(event:FlexEvent):void
                  <s:HTTPService id="resultExample"
                <s:TextInput x="145" y="274" id="firstcode"/>


                XML file "provadati.xml":


                <code>  pear</code>
                <code>apple  </code>



                When I run the application I can see on TextInput the value "pear,apple  ", whitespaces at the end are preserved but at the begin not.

                If I set "XML.ignoreWhitespace=true" the result is that blankspaces at the end are trimmed, as expected.

                I hope I explain correctly my problem and I thanks for the replies, have you any ideas on what can I do?