So on to the code:
//in this example the structure that we will create is like this and stored in a file named "music.xml":
//<music>
//<newFile>
//<id>...</id>
//<title>...</title>
//<urlID>...</urlID>
//<descriptionID>...</descriptionID>
//<dateID>...</dateID>
//</newFile>
//...
//
// have in mind that the initial tag
// add the nodes in there
//we create the http request that will transfer the data to the php file upon call
<mx:HTTPService id="filePush" showBusyCursor="true" url="assets/xmlWriter.php" headers="null" requestTimeout="18" resultFormat="e4x"
contentType="application/x-www-form-urlencoded" method="GET">
<mx:request>
<id>{getID()}</id>
<title>{titlePush.text}</title>
<url>{urlString+titlePush.text}</url>
<date>{date_str}</date>
<desc>{desc.text}</desc>
</mx:request>
</mx:HTTPService>
//now we throw in some Action script
//to create a unique id for all entries
public function getID():Number
{
var start:Number=Math.round(Math.random()*today_date.getFullYear());
start=(start+(today_date.getMonth()+1)+today_date.getDay())*today_date.getSeconds();
return start;
}
//and for the Date
[Bindable]
public var today_date:Date = new Date();
public var date_str:String = (today_date.getDate()+"/"+(today_date.getMonth()+1)+"/"+today_date.getFullYear());
//==========================================
//and finaly the PHP code, pretty straightforward using SimpleXML:
<?php
$file="music.xml";
$xml=simplexml_load_file($file) or die ("Unable to load XML");
$vitals = $xml->addChild('newItemID');
$vitals->addAttribute('id', $_GET['id']);
$vitals->addChild('titleID', stripcslashes($_GET['title']));
$vitals->addChild('urlID', $_GET['urlID']);
$vitals->addChild('dateID', $_GET['date']);
$vitals->addChild('descriptionID', stripcslashes($_GET['desc']));
$doc = new DOMDocument('1.0');
$doc->preserveWhiteSpace = false;
$doc->loadXML( $xml->asXML());
$doc->formatOutput = true;
file_put_contents( $file, $doc->saveXML());
?>
for the editing part wait for my next post which won't be too late!
Enjoy!