Hi,
I am actually testing the XML tutorial from adobe and I would like to add data directly in the XML file.
Here is the xml file :
Model (bloggers.xml)
<bloggers>
<blogger>
<name>Andy Budd</name>
<url>http://andybudd.com</url>
</blogger>
<blogger>
<name>Grant Skinner</name>
<url>http://gskinner.com</url>
</blogger>
<blogger>
<name>Paul Booth</name>
<url>http://paulbooth.com</url>
</blogger>
</bloggers>
And here the main application file :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
viewSourceURL="src/DataProviderExternal/index.html"
width="350" height="220"
creationComplete="bs.send();"
>
<mx:Script>
<![CDATA[
import mx.managers.CursorManager;
import mx.rpc.events.InvokeEvent;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var bloggersCol:ArrayCollection;
// Gets called when HTTPService is invoked to
// request the XML.
private function bsInvokeHandler(event:InvokeEvent):void
{
// Display the busy cursor
CursorManager.setBusyCursor();
}
// Gets called when the XML is successfully loaded.
private function bsResultHandler(event:ResultEvent):void
{
// Save a reference to the list of bloggers
bloggersCol = event.result.bloggers.blogger;
// Hide the busy cursor
CursorManager.removeBusyCursor();
}
private function bsFaultHandler(event:FaultEvent):void
{
// There was an error in loading the XML
Alert.show (event.fault.message);
// Hide the busy cursor
CursorManager.removeBusyCursor();
}
]]>
</mx:Script>
<!-- Service to load in XML -->
<mx:HTTPService
id="bs"
url="data/bloggers.xml"
invoke="bsInvokeHandler(event);"
result="bsResultHandler(event);"
fault="bsFaultHandler(event);"
/>
<mx:Panel title="Bloggers we love!" width="100%">
<mx:List
id="bloggersList" width="100%" rowCount="4"
dataProvider="{bloggersCol}"
labelField="name"
/>
<mx:ControlBar horizontalAlign="center">
<mx:Button
label="Add a blogger!"
click="bloggersCol.addItem({name:'Pete-Barr Watson', url:'http://petebarrwatson.com/'});"
/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>
is there any possibility to make the data directly into the XML file without using a server ?
thank you