0 Replies Latest reply on Feb 26, 2008 6:13 AM by sulletf

    XML validation

    sulletf
      Hi!

      In the following example, typing plain text in the TextArea and clicking the button returns OK ! Why ??

      When tag characters are input, then controls are perfectly as expected.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

      <mx:Script>
      <![CDATA[

      private function checkXML():void {

      try { var x:XML = new XML( ti.text ); }
      catch(error:Error) {
      mylabel.text = 'KO';
      mylabel.setStyle('color', 0xCC0000);
      return;
      }
      mylabel.setStyle('color', 0x009900);
      mylabel.text = 'OK';

      }

      ]]>
      </mx:Script>

      <mx:TextInput id="ti" width="400" height="200" />

      <mx:Button id="myButton" click="checkXML()" />
      <mx:Label id="mylabel" />

      </mx:Application>