try
{

var readscoreContents;

var xmlfilename = Titanium.Filesystem.getResourcesDirectory() + "database.xml";
var readscoreFile = Titanium.Filesystem.getFile(Titanium.Filesystem.getResourcesDirectory(), "database.xml");
var fs = Titanium.Filesystem.getFileStream(readscoreFile);

if (readscoreFile.exists())
{
//readscoreFile.open(Titanium.Filesystem.MODE_WRITE, true);


fs.open(Titanium.Filesystem.MODE_WRITE);


readscoreContents = fs.read();
}

var xmlscoreDoc;
var xmlscoreString =readscoreContents.toString();

if (document.implementation.createDocument) {
var sparser = new DOMParser();
xmlscoreDoc = sparser.parseFromString(xmlscoreString, "text/xml");

} else if (window.ActiveXObject) {
xmlscoreDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlscoreDoc.async="false";
xmlscoreDoc.loadXML(xmlscoreString);
}

var root = xmlscoreDoc.getElementsByTagName('score');
var root2 = xmlscoreDoc.getElementsByTagName("scores")[0];


var newel=xmlscoreDoc.createElement("score");
root2.appendChild(newel);


fs.write(xmlscoreDoc);


//xmlscoreDoc.Save(Titanium.Filesystem.getResourcesDirectory()+"/database.xml");
//root.length

//Titanium.API.info(root[0].getAttribute('flag'));



//Titanium.API.info(root[1].childNodes[0].nodeValue);

}
catch(e)
{
Titanium.API.info(e);

}