本文介绍了XMLHttpRequest - 解析返回的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人运行任何测试来比较解析XML与简单列表中的文本的速度 - 例如:


<?xml version =" 1.0" encoding =" ISO-8859-1"?>

< users>

< user>用户1< / user>

< user>用户2< / user>

< user>用户3< / user>

< / users>


并使用.responseXML检索

vs:


用户1 |用户2 |用户3


然后使用.split(''''')来解析.responseText


只是好奇心问题 - thx!

解决方案






道格拉斯 - 也许更容易处理。但是我最感兴趣的是

当下是执行的速度。


如果这样的测试还没有完成,我会可能做一个 - 我只是

想看看它是否已经先完成了。


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




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




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.


这篇关于XMLHttpRequest - 解析返回的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:07