2/1/2010 11:35:31 PM
Title:
convert mxml file to xml
i need to know how to convert mxml file into xml?
thanks in advance
2/2/2010 12:24:35 AM
Simple just rename the yourfile.mxml to yourfile.xml.
MXML file is alreay an xml format .
2/2/2010 2:18:16 AM
i want to create an xml file of a component(titlewindow) during run time in flex application.can u help.
thanks in advcance
2/2/2010 2:45:15 AM
Do you want to create file on hard disk , or server . If so you have to use serverside like php.
For a title window xml can be like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768">
<mx:TitleWindow x="56" y="42" width="250" height="200" layout="absolute" title="Title Window">
</mx:TitleWindow>
</mx:Application>
2/2/2010 3:03:17 AM
in flex builder i first created a component(titlewindow) with some controls in it,now i want to create an xml file of the object(titlewindow) during runtime in mxml application.
thanks in advance
Inder
Points: 2480
Posts:0
2/2/2010 3:43:20 AM
Hi rani,
you can use a for loop to get list of all the compoenents and there properties an then use it to create an xml file like this . Below is a simple xml , You can create your own format as you like . Below code makes xml of componennts in a title window like this :
--------------------------------------
<Button6 width=65 height=22/>
<Label8 width=35 height=18/>
<Image10 width=0 height=0/>
----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768" applicationComplete=" makeXML()">
<mx:Script>
<![CDATA[
private function makeXML():void{
trace(titleComponent.getChildren().length)
for(var i:int=0;i<titleComponent.getChildren().length;i++){
//you can get all the propeties and names of all the components
//create here your xml using those properties and names
var currentComponent=titleComponent.getChildAt(i)
trace("<"+currentComponent.name+" width="+currentComponent.width+" height="+currentComponent.height+"/>")
}
}
]]>
</mx:Script>
<mx:TitleWindow id="titleComponent" x="56" y="42" width="250" height="200" layout="absolute" title="Title Window">
<mx:Button x="59" y="27" label="Button"/>
<mx:Label x="59" y="57" text="Label"/>
<mx:Image x="59" y="83"/>
</mx:TitleWindow>
</mx:Application>
2/2/2010 5:59:45 AM
hi Redni
i m getting xml file of titlewindow when i m creating titlewindow as u hv given in code
but when i m creating a titlewindow during reun time it is not giving result,cna u tell why i can't access children of titlewindow when i m creating it as component and adding it as child during runtime in mxml application.
Inder
Points: 2480
Posts:0
2/2/2010 6:12:26 AM
make sure that :
the reference ID of runtime window is passed to the function, If you are creating titlewindow dynamically then you must call the makeXML(idofComp) function after it is created and pass the id of titlewindow component. I am using the static titlewindow whose id is titleComponent. In your case use the variable idofComp which you will be passing to makeXML(idofComp).
If still not working then verify by tracing that the component idofComp is available in the function.