471,831 Members | 765 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

fastest way to load and process 100 rows variable

I got a javasscript based aplication, which is working with data from
server (php&sql, changed once per week or so). Actualy I use a xml as a
data format with structure e.g.
[item var1="smthng" var2="123" var3="456" var4="ABC" /]
I open read the file through XMLHttpRequest and then i do smtg like

items = documentElement.getElementsByTagName("item");
for i=0 to items.lenght {
var1=item[i].getAttribute("var1")
....
function(var1, var2, var3, var4)
}

The problem is, that it is quite slow with 100 items i'am sometimes
over 5 secs total execution time on firefox and it than write an error
message. The others browsers do not write this message, but they are
even slower, up to 20 secs for IE
The slow thing is that file access and making a variable from it.

If wonder that there may be some much faster way, as i do not need the
data to be in xml, i can make any data format, i can even make
something like var dump. But i do not know how to parse this dump to
variable, and i do not know if it will be faster

Or are there some other fast ways how to quicker load the data?

Aug 7 '06 #1
1 1416

TKapler wrote:
I got a javasscript based aplication, which is working with data from
server (php&sql, changed once per week or so). Actualy I use a xml as a
data format with structure e.g.
[item var1="smthng" var2="123" var3="456" var4="ABC" /]
I open read the file through XMLHttpRequest and then i do smtg like

items = documentElement.getElementsByTagName("item");
for i=0 to items.lenght {
var1=item[i].getAttribute("var1")
...
function(var1, var2, var3, var4)
}

The problem is, that it is quite slow with 100 items i'am sometimes
over 5 secs total execution time on firefox and it than write an error
message. The others browsers do not write this message, but they are
even slower, up to 20 secs for IE
The slow thing is that file access and making a variable from it.

If wonder that there may be some much faster way, as i do not need the
data to be in xml, i can make any data format, i can even make
something like var dump. But i do not know how to parse this dump to
variable, and i do not know if it will be faster

Or are there some other fast ways how to quicker load the data?
Try JSON:

<URL: http://www.json.org/ >

e.g.

// jsonTxt is returned by the XMLHttpRequest
// Preferrably machine generated, getting the syntax right
// can be tricky if done manually
var jsonTxt =
'{'
+ 'item0 : ["smthng", "123", "456", "ABC"],'
+ 'item1 : ["nudder", "asd", "dfgh", "D"],'
+ 'item2 : ["anudder", "lkj", "oiu", "E"]'
+ '}';

var items = eval( '(' + jsonTxt + ')' );

function showArgs(){
var args = [];
for (var i=0; i<arguments.length; i++){
args.push(arguments[i]);
}
alert(args.join('\n'));
}

showArgs(items.item1[0], items.item1[1], items.item1[2]);

--
Rob

Aug 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by laurenq uantrell | last post: by
5 posts views Thread by N | last post: by
reply views Thread by chad kline | last post: by
3 posts views Thread by db2udbgirl | last post: by
3 posts views Thread by Sehboo | last post: by
4 posts views Thread by Chris Nethery | last post: by
3 posts views Thread by Code Monkey | last post: by
3 posts views Thread by M.-A. Lemburg | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.