2 Replies Latest reply on Jan 12, 2011 9:01 AM by saisri2k2

    Create XML file

    capitainequebec Level 1

      I am using AIR and FileStream class to save file locally but I don"t know how to create XML file using AS. I think I should use something like this:


      var xmlPoincon:XML = new XML();


      But I don't know how to create the node of the XML and then the values.



      Daniel Cantin




        • 1. Re: Create XML file
          Gregory Lafrance Level 6

          Here is a simple code snippet:


          private function createXML(): void{
              var xm:XML = <Relyon></Relyon>;
              var nodeName:String = "EMPLOYEENAME";
              var nodeValue:String = "KUMAR";
              var xmlList:XMLList = XMLList("<"+nodeName+">"+nodeValue+"</"+nodeName+">");


          Most important here is the appendChild() method, that allows you to add a node you have constructed.




          If this post answers your question or helps, please mark it as such. Thanks!

          Adobe Flex Development and Support Services

          • 2. Re: Create XML file
            saisri2k2 Level 4

            programmatically you can do the following

            var xmlPoincon:XML = new XML();
                           protected function application1_creationCompleteHandler(event:FlexEvent):void
                                var root:XML = <root></root>; 
                                var firstElement:XML = <subElement>{"value"}</subElement>;
                                xmlPoincon = root;


            it will give




            else you can give


            var xmlPoincon:XML = <root>


            the above will work as well.

            1 person found this helpful