1 Reply Latest reply on Apr 18, 2011 7:17 PM by Lee Burrows

    Flex / Actionscript - why wont 'XML.ignoreWhitespace = false' work?

    DilipShah Level 1
      The following simple codes show how I'm trying to keep  white space in my XML but it doesn't work! Any idea what I'm doing wrong  here?
      ======
      <?xml version="1.0" encoding="utf-8"?>
      <s:Application
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          minWidth="955" minHeight="600"
          creationComplete="application1_creationCompleteHandler(event)"
          >
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <fx:Script>
              <![CDATA[
                  import mx.events.FlexEvent;
                  import mx.controls.Alert;
                 
                  XML.ignoreWhitespace = false;
                 
                  protected function application1_creationCompleteHandler(event:FlexEvent):void {
                      var xmlString:String =
                          "<sentence><word1>hello</word1><word2> world!</word2></sentence>";
                      trace(xmlString);
                     
                      XML.ignoreWhitespace = false;
                     
                      var xml:XML =
                          new XML(xmlString);
                      trace(xml.toXMLString());
                      Alert.show(xml.toXMLString());
                  }
                 
              ]]>
          </fx:Script>
      </s:Application>

       

      ======
      Please help... Thanks!