473,385 Members | 2,210 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,385 software developers and data experts.

XMLHttpRequest - parsing returned data

I'm wondering if anyone has run any tests to compare the speed of
parsing XML vs text in simple lists - such as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<users>
<user>User 1</user>
<user>User 2</user>
<user>User 3</user>
</users>

and retrieving using .responseXML
vs:

User 1|User 2|User 3

then using .split('|') to parse the .responseText

Just a matter of curiosity - thx!

Dec 18 '05 #1
10 5329
VK

Tony wrote:
I'm wondering if anyone has run any tests to compare the speed of
parsing XML vs text in simple lists - such as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<users>
<user>User 1</user>
<user>User 2</user>
<user>User 3</user>
</users>

and retrieving using .responseXML
vs:

User 1|User 2|User 3

then using .split('|') to parse the .responseText

Just a matter of curiosity - thx!


That collides with a rather old discussion "What's wrong with AJAX":
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/f6ce0a5e95d8bf30/95c4d63e4c82f068>

Still the whole year 2005 has been spent by numerous users to
re-discover an open-source fact: for explicit script handling XML is
the least convenient and the most uneffective format one could imagine.
But Microsoft IXMLHTTPRequest was never minded to be used in such way.
It was merely further evolution of *data binding*: one click to change
the source leads to "zero maintenance" page update.
The curved path by where the things went can be traced back to the
famous Adaptive Path article
<http://www.adaptivepath.com/publications/essays/archives/000385.php>

By simply reading posts in this newsgroup one can trace the development
from the initial attempt to use AJAX for XML - to the final use as a
simple responseText grabber where the responseText evolutionated from
some XML-like format to script-ready and script-friendly format close
to the serialized object form.
Eventually as I expected people dropped any XML-attempts whatsoever and
started to move to JSON (or JSON clones) as transport media.

Next year I see further evolution of AJAX/JSON symbiotic use, but it is
a limited path because of AJAX same-domain limitation. It makes it hard
to use in a complex corporate environment (with different sub-domains
and even domains). Also it is not usable for server-side free RSS
feeds. After the users will be fed up enough of this: they will move on
some cross-domain free solution like script.src (or something else).
Initially it will be kind of hack, but it will be eventually blessed
into standards as soon as it will get enough popularity. I accept bets
on it as 2:1 :-)

Another great influence of AJAX is the power demonstration of users to
browser producers and standard writers. Some browsers could not /
refused to implement the most basic features for years. So more amazing
it was to watch the entire year how they rushed to implement or at
least mimic XMLHttpRequest functionality to not loose their users. And
they actually *fixed all bugs in a timely manner*, sometimes within a
month! Just for this reminder who is the customer and who is the humble
service provider - just for this we have to love AJAX.

IMHO

Dec 18 '05 #2
Tony wrote:
I'm wondering if anyone has run any tests to compare the speed of
parsing XML vs text in simple lists - such as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<users>
<user>User 1</user>
<user>User 2</user>
<user>User 3</user>
</users>

and retrieving using .responseXML
vs:

User 1|User 2|User 3

then using .split('|') to parse the .responseText

Just a matter of curiosity - thx!


You might consider using JSON instead of XML.

{"users": ["User 1", "User 2", "User 3"]}

It is a whole lot easier to handle.

http://www.JSON.org
Dec 19 '05 #3
>That collides with a rather old discussion "What's wrong with AJAX":
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread...>
VK - thanx for the link, but I didn't see much relating to my specific
question. I'll admit to perhaps being dense - if I missed it, I would
appreciate a little direction :)
You might consider using JSON instead of XML.

{"users": ["User 1", "User 2", "User 3"]}

It is a whole lot easier to handle.


Douglas - easier to handle, perhaps. But what I'm most interested in at
the moment is speed of execution.

If such a test hasn't been done, I will probably do one - I just
wanted to see if it was already done first.

Dec 19 '05 #4
VK

Tony wrote:
If such a test hasn't been done, I will probably do one - I just
wanted to see if it was already done first.


Any DOM method call is much longer than a JavaScript native method. It
is kind of "prove me in 1 min that the Earth is a globe" :-) Out of
immediate arguments right now but I'm sure that there is somethere a
fact sheet of in-script methods vs. outside (DOM) methods call.

With JSON (or JSON-like) approach you have to deal with DOM only once:
while feeding processed results to your document.
With XML you have to do it twice: first to parse XML data, second to
feed the document. Plus this - minus that - and being conservative - I
predict at least 30% speed increase. Would be great to know what kind
of Kassandra am I :-)

Dec 19 '05 #5
On 18 Dec 2005 17:37:31 -0800, "Tony" <to****@dslextreme.com> wrote:
You might consider using JSON instead of XML.

{"users": ["User 1", "User 2", "User 3"]}

It is a whole lot easier to handle.


Douglas - easier to handle, perhaps. But what I'm most interested in at
the moment is speed of execution.


JSON is orders of magnitude faster than XML in almost all situations,
in almost all UA's, please confirm this yourself, but I'd be shocked
if you find different.

Jim.
Dec 19 '05 #6
On Mon, 19 Dec 2005 00:58:22 GMT, in comp.lang.javascript , Douglas
Crockford <no****@sbcglobal.net> in
<OA*******************@newssvr14.news.prodigy.co m> wrote:
Tony wrote:
I'm wondering if anyone has run any tests to compare the speed of
parsing XML vs text in simple lists - such as:

<?xml version="1.0" encoding="ISO-8859-1"?>
<users>
<user>User 1</user>
<user>User 2</user>
<user>User 3</user>
</users>

and retrieving using .responseXML
vs:

User 1|User 2|User 3

then using .split('|') to parse the .responseText

Just a matter of curiosity - thx!


You might consider using JSON instead of XML.

{"users": ["User 1", "User 2", "User 3"]}

It is a whole lot easier to handle.

http://www.JSON.org


ISTM that there two major differences is that JSON does not have a
doctype so we can validate against some external definition and it
does not have explicit closing tags. Is that correct?
--
Matt Silberstein

Do something today about the Darfur Genocide

http://www.beawitness.org
http://www.darfurgenocide.org
http://www.savedarfur.org

"Darfur: A Genocide We can Stop"
Dec 19 '05 #7
>>You might consider using JSON instead of XML.

{"users": ["User 1", "User 2", "User 3"]}

It is a whole lot easier to handle.

http://www.JSON.org

ISTM that there two major differences is that JSON does not have a
doctype so we can validate against some external definition and it
does not have explicit closing tags. Is that correct?


JSON does not have doctypes because it is not a document format. It is
a data interchange format. It is easy to determine that the data
delivered is syntactically correct (or "well formed"). Ultimately,
data must be verified by the application that consumes it. This cannot
be done syntactically. Verification is easier to do in JSON because
the structure of the data conforms to the affordances of the
programming language.

JSON does not have tags, so it does not have closing tags. It does
have syntactic structure, using { ... } to wrap unordered collections
of key/value pairs, and [ ... ] to wrap sequences of values.
Dec 19 '05 #8
VK wrote:
Any DOM method call is much longer than a JavaScript native method.


That statement, in and of itself, is pure nonsense, regardless what
meaning may be attached to the words.
PointedEars
Dec 19 '05 #9
> VK wrote:
Any DOM method call is much longer than a JavaScript native method.

That's about what I suspected - but I was hoping for something more
than suspicion to go on...

Thomas 'PointedEars' Lahn wrote:
That statement, in and of itself, is pure nonsense, regardless what
meaning may be attached to the words.


Would you please clarify your meaning?

Dec 19 '05 #10

Tony wrote:
I'm wondering if anyone has run any tests to compare the speed of
parsing XML vs text in simple lists [...] From <URL:http://blogs.ebusiness-apps.com/dave/?p=45> we can think that

JSON is slightly faster (or equal) than XML when there dataset is
small... bigger datasets are parsed faster for XML...

I guess that only reason for it is not native implementation of JSON
parser... i also guess that native implementation of JSON parser would
be faster then XML.

Whole thing would be better is Web API Working Group would add
extension to XMLHttpObject, so between responseText and responseXML
there could be

XMLHttpObject.responseJSON

, which will return 'data' JavaScript object...not just for speed
purpose, but for 'easyness' of mainipulating JSON object at JavaScript
side (even at other langueges sides - beacause there are also
implementations for other languages...).

I think that there is reason to write to Web API wokring group
<URL:http://www.w3.org/2006/webapi/> to include it in futer
recomendation of it, but first step is for Douglas Crockford to do so.

Dec 19 '05 #11

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

Similar topics

6
by: Chris Smith | last post by:
This is a bit of a weird problem. Unfortunately, I can't reproduce it in a simple example, so I can only poke it out there and see if anyone has seen something similar. I have a script that...
3
by: spark | last post by:
I have been experimenting with xmlhttprequest. (I am a javascript newbie, but familiar with programming with VB, Perl, and some PHP.) I am trying to see if it's possible to receive html snippets...
22
by: googlegroups | last post by:
I am playing with the XMLHTTPRequest method to perform client/server transactions. I have it set up right now so that when readyState is 4, it takes the XML and processes it. This works great until...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
13
by: iannorton | last post by:
Hi there, I Recently started experimenting with AJAX and succesfully created an autocomplete box using a script that returned html from a serverside javascript page. I'm now at the point...
7
by: Noozer | last post by:
I've been doing some reading about "AJAX" and it sounds pretty interesting. While I can make it work, it seem like I'm doing much of it the "hard way". I was wondering what kind of code that others...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
13
by: My Pet Programmer | last post by:
The way I usually set up and work with the XMLHttpRequest to execute server side functions and get results is this: var url = "someurl?params=" + params; var conn = createRequest(); // gets an...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.