473,329 Members | 1,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

xml vs arrays

I have a web document created by a script and instead of going back to
the db I choose to either create an array to iterate through or xml to
parse through.

So, my question is: What are the trade offs between using an array to
load data from or an xml structure?

My array would look like:

myarray = [[],[],[],[]]

My xml like:

<xml>
<data>
<a></a><b></b>
</data>
</xml>

I would use js to iterate or getElementByTagName to find data.

I am thinking the page would load faster using xml, and then the user
may not even use that functionality. In all cases I have to load the
array to memory.

Thoughts?

Jul 23 '05 #1
5 1769
mike wrote:
I have a web document created by a script and instead of going back to
the db I choose to either create an array to iterate through or xml to
parse through.

So, my question is: What are the trade offs between using an array to
load data from or an xml structure?

My array would look like:

myarray = [[],[],[],[]]
Wouldn't that be an object?

My xml like:

<xml>
<data>
<a></a><b></b>
</data>
</xml>

I would use js to iterate or getElementByTagName to find data.

I am thinking the page would load faster using xml, and then the user
How? Data transmitted as an XML file would likely be 2 to 10 times
bigger than the same data as an array/object in a JavaScript file,
significantly affecting load times over the Internet (but perhaps not
so much over intranet).

I would also expect any methods on the array/object to be faster than
using getElement... methods with the same data as an XML document
(though that is untested and may be dependent on the data structure).
may not even use that functionality. In all cases I have to load the
array to memory.

An array/object is loaded without effort, I doubt that would be
slower than loading than parsing an XML file.
Thoughts?


XML is primarily for the exchange of data where the overhead of
creating the structure, transmitting it, then parsing it at the other
end is outweighed by the increased efficiency of standard data
formats. It is very inefficient for nearly any other purpose.

--
Zif
Jul 23 '05 #2
Zifud wrote:
myarray = [[],[],[],[]]
Wouldn't that be an object?


That's an array owning a property "length" of value "4".
Each of the array's elements is an (empty) array.

Of course every array is an object, too (typeof myarray
would result in "object" as for every array).

ciao, dhgm
Jul 23 '05 #3
mike wrote:
I have a web document created by a script and instead of going back to
the db I choose to either create an array to iterate through or xml to
parse through.

So, my question is: What are the trade offs between using an array to
load data from or an xml structure?

My array would look like:

myarray = [[],[],[],[]]

My xml like:

<xml>
<data>
<a></a><b></b>
</data>
</xml>

I would use js to iterate or getElementByTagName to find data.

I am thinking the page would load faster using xml, and then the user
may not even use that functionality. In all cases I have to load the
array to memory.

Thoughts?


You should be using JSON. It will be much faster than XML.

http://www.JSON.org
Jul 23 '05 #4
The xml is embedded in the page already, another file does not have to
be read. It is an xml structure contained in the page.

So, what you are saying is that parsing through an array is much faster
than iterating an xml structure.

What if we used a xsl stylesheet and did a transformation?

Jul 23 '05 #5
Lee
mike said:

The xml is embedded in the page already, another file does not have to
be read. It is an xml structure contained in the page.

So, what you are saying is that parsing through an array is much faster
than iterating an xml structure.

What if we used a xsl stylesheet and did a transformation?


In that case, the array would be *much* faster.
You're not going to get faster than the native array or object
literal notation.

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
5
by: JezB | last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of files that match one of 3 search patterns, so I need something like DirectoryInfo ld = new DirectoryInfo(searchDir);...
3
by: Michel Rouzic | last post by:
It's the first time I try using structs, and I'm getting confused with it and can't make it work properly I firstly define the structure by this : typedef struct { char *l1; int *l2; int Nval; }...
1
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
6
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get:...
1
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
16
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
29
weaknessforcats
by: weaknessforcats | last post by:
Arrays Revealed Introduction Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with arrays and array syntax but is not clear on a )exactly how...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.