Hi Vinod, Thankx for replying.. and this is a Air application only..
I am pasting the Full coding so u can have a review and reply for me ////////////////////////////////////////////////////////////////////// for Saving the Xml of Nodes and attributes and their Contents Also <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.listClasses.ListData; import mx.events.DataGridEvent; import mx.events.FlexEvent; import mx.collections.ArrayCollection; import mx.messaging.management.Attribute; import mx.controls.DataGrid; import mx.controls.TextArea; import mx.controls.dataGridClasses.DataGridColumn; import mx.controls.Alert; import mx.events.ListEvent; [Bindable] private var fileXML:XML; private var dataXML:XML; private var file:File; private var xmll:XMLList = new XMLList(); private var nodeText:TextArea = new TextArea(); private var nodeName:TextArea = new TextArea(); private var attributeText:TextArea = new TextArea(); private var nodeGrid:DataGrid = new DataGrid(); private var ac:ArrayCollection; private var rootName:String; private var xml:XML; private var xind:String ; private function loadXML():void{ file = new File(); file.addEventListener(Event.SELECT, dirSelected); file.browseForOpen("Select xml file"); } private function dirSelected(e:Event):void{ var fs:FileStream = new FileStream(); fs.open(file, FileMode.READ); fileXML = XML(fs.readUTFBytes(fs.bytesAvailable)); fs.close(); } private function tree_labelFunc(item:Object):String { trace("Tree label function ::"); var suffix:String = ""; if (tree.dataDescriptor.isBranch(item)){ return item.name()+suffix; } else{ return item+''; } } private function tree_itemClick(evt:ListEvent):void { var t:Tree = evt.currentTarget as Tree; dataXML = evt.itemRenderer.data as XML; displayFields(); xind=String(t.selectedItem.name()); } private function removeContents():void{ var allObj:Array = [nodeGrid,nodeName,nodeText]; for(var i:int = 0 ; i<allObj.length;i++){ if(box.contains(allObj[i])){ box.removeChild(allObj[i]); } } } private function addContent(cont:DisplayObject):void{ if(box.contains(cont)){ } else{ box.addChild(cont); } } private function displayFields():void{ rootName = ''; ac = new ArrayCollection(); removeContents(); var attributes:XMLList = dataXML.attributes(); var attributeNames:String = ''; var attributeContent:String = ''; for(var k:uint = 0; k < attributes.length(); k++) { attributeNames = attributes[k].name(); attributeContent = attributes[k].toString(); var obj:Object = []; obj = {Name:attributeNames,Value:attributeContent} ac.addItem(obj); } if(attributeNames!=''){ nodeGrid.dataProvider = ac; nodeGrid.addEventListener(DataGridEvent.ITEM_FOCUS_OUT,onEditEnd); nodeGrid.editable = true; nodeGrid.percentWidth = 100; addContent(nodeGrid); } if(dataXML.name()) { nodeName.text = dataXML.name(); nodeName.percentWidth = 100; addContent(nodeName); } else{ nodeText.text = dataXML.toString(); nodeText.percentWidth = 100; addContent(nodeText); } save_btn.enabled = true; } private function onEditEnd(event:DataGridEvent):void { var nameString:String = DataGrid(event.currentTarget).selectedItem.Name; fileXML[xind]["@"+nameString] = DataGrid(event.currentTarget).selectedItem.Value; } private function saveXML():void { var newXMLStr:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + fileXML.toXMLString(); var fs:FileStream = new FileStream(); fs.open(file, FileMode.WRITE); fs.writeUTFBytes(newXMLStr); fs.close(); } ]]> </mx:Script> <mx:VBox width="100%" height="100%"> <mx:HDividedBox width="100%" height="100%"> <mx:Panel width="220" height="100%" paddingRight="10" paddingLeft="10" paddingBottom="10" paddingTop="10"> <mx:Tree id="tree" dataProvider="{fileXML}" labelFunction="tree_labelFunc" width="100%" height="100%" itemClick="tree_itemClick(event);" /> <mx:HBox horizontalAlign="center" verticalAlign="middle"> <mx:Button id="load_btn" label="Load XML" click="loadXML()"/> <mx:Button id="save_btn" label="Save XML" click="saveXML()" enabled="false"/> </mx:HBox> </mx:Panel> <mx:Panel id="panel" width="100%" height="100%" paddingRight="10" paddingLeft="10" paddingBottom="10" paddingTop="10" backgroundColor="white"> <mx:VBox id="box" width="100%" height="100%"> </mx:VBox> <mx:ControlBar> </mx:ControlBar> </mx:Panel> </mx:HDividedBox> </mx:VBox> </mx:WindowedApplication> ////////////////////////////////////////////////////////////////////////////////////////////////////////////// Regards, R.Denesh Kumar On Thu, Nov 13, 2008 at 12:45 PM, Vinod M Jacob <[EMAIL PROTECTED]> wrote: > > You cannot save the overwritten conent in xml and store it as Venkat > suggested without using AIR. > But you can change the collection object.For that check the XML > opeartions which are restricted to a few.It will be better if you > store the object into a arraycollection or XMLListCollection as more > operation are allowed here. > > On Nov 12, 6:37 pm, "Denesh Kumar.R" <[EMAIL PROTECTED]> wrote: > > Hi Guys, > > > > Waiting for Solution..................... > > > > Regards, > > R.Denesh Kumar > > > > > > > > ---------- Forwarded message ---------- > > From: Denesh Kumar.R <[EMAIL PROTECTED]> > > Date: Thu, Nov 6, 2008 at 4:29 PM > > Subject: saving xml in flex 3 > > To: [EMAIL PROTECTED] > > > > Hi > > > > I want to open and edit the xml and to be saved any sample code..plz > > > > Thanks in Advance > > > > R.Denesh Kumar > > ______________ > > Enjoy the Life.. > > > > -- > > R.Denesh Kumar > > ______________ > > Enjoy the Life..- Hide quoted text - > > > > - Show quoted text - > > > -- R.Denesh Kumar ______________ Enjoy the Life.. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

