Thanks, Gary. No luck with localStorage in WebViewer yet, tho. :(
I need to rephrase my last comment as it was misleading.
Taifun was able to read a local text file with XMLHttpRequest() http://puravidaapps.com/read.php
and I was hoping to do the same for saving a local text file but have not found a solution that works with the WebViewer component yet that does not require a server.
Sorry, slightly off topic but "can java script parse xml into lists ?, if so , could it do it faster than appinventor ?appinventor seems to slow down a lot when parsing xml of an irregular layout (as you need to test for whether a tag is present in the response, then to parse that tag)I see web browsers do it in a tenth of the time, could that happen without local storage ?
Taifun has shown that math in javascript is much faster than App Inventor, so I would think that XML parsing would likely be faster as well. It should not matter where your document is located. Javascript works on a server or local ly, but it is actually executing on the client machine, not the server.
<planets>
<planetname>Ligo,Xiavolux,Caladan,Mamuut,Ensilore,Nausdor</planetname>
<population>3 billon,15 billion,28 billion,9.5 billion,21.2 billion,7 billion</population>
<government>Corporate State,Democracy,Dictatorship,Feudal,Anarchy,Confederacy</government>
<techlevel>5,10,3,8,4,9</techlevel>
<economy>Poor agricultural,Rich industrial,Meduim industrial,Rich agricultural,Poor industrial,Medium agricultural</economy>
</planets>
<!DOCTYPE HTML><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>Read File</title><script type="text/javascript">function run() {xmlhttp=new XMLHttpRequest();xmlhttp.open("GET","datafortinydb.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML;// get the items inside each xml tag and put it in a variablevar planetname=xmlDoc.getElementsByTagName("planetname")[0].childNodes[0].nodeValue;var population=xmlDoc.getElementsByTagName("population")[0].childNodes[0].nodeValue;var government=xmlDoc.getElementsByTagName("government")[0].childNodes[0].nodeValue;var techlevel=xmlDoc.getElementsByTagName("techlevel")[0].childNodes[0].nodeValue;var economy=xmlDoc.getElementsByTagName("economy")[0].childNodes[0].nodeValue;// add lines here for any extra variables you want to bring in// print all variables to the document title, separated by |window.document.title = planetname+"|"+population+"|"+government+"|"+techlevel+"|"+economy; // add variables here for additonal tags}</script></head><body onLoad="run();"></body></html>
Off topic, the only thing I don't like about this method are all the permissions required - modify/delete SD storage, read phone state, full internet access.. for just a few blocks of code.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Read File</title>
<script type="text/javascript">
function run() {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","datafortinydb.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
// work out tagNames and grab data from inside each tag
var x=xmlDoc.documentElement;
var realChilds=0;
var parent=x;
var child=parent.childNodes.length;
var i = 0;
var nameofNode="";
var itemsinNode;
while(i < child){
if(parent.childNodes[i].nodeType != 3){
realChilds++;
nameofNode=parent.childNodes[i].nodeName;
itemsinNode=itemsinNode+"|"+xmlDoc.getElementsByTagName(nameofNode)[0].childNodes[0].nodeValue;
}
i++;
}
// print all variables to the document title
window.document.title = itemsinNode;
Thanks, Taifun, but I don't want to have to use the Internet to download an html document on first run.