Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
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); }
This paste will be private.
From the Design Piracy series on my blog: