XMLHttpRequest - 解析返回的数据 [英] XMLHttpRequest - parsing returned data

查看:55
本文介绍了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!

解决方案



Tony写道:

我想知道是否有人运行任何测试来比较
在简单列表中解析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!



与一个相当陈旧的讨论相撞AJAX出了什么问题:

< http://groups.google.com /group/comp.lang.javascript/browse_frm/thread/f6ce0a5e95d8bf30/95c4d63e4c82f068>


2005年全年仍然被无数用户花费了很多钱来支付
re - 发现一个开源事实:对于显式脚本处理XML是最简单方便且最无效的格式。

但Microsoft IXMLHTTPRequest从未被认为是以这种方式使用。

这只是为了满足*数据绑定的演变*:一键点击改变

来源导致零维护页面更新。

路径所在的弯曲路径可以追溯到

着名的自适应路径文章

< http:/ /www.adaptivepath.com/publications/essays/archives/000385.php>


只需阅读本新闻组中的帖子,就可以追踪开发

来自最初尝试使用AJAX进行XML - 最终用作

简单的responseText采集器,其中responseText从

演变为类似XML的格式到脚本就绪和脚本友好的格式关闭

到序列化的对象表格。

最后,正如我所料,人们放弃了任何XML尝试,并且

开始转向JSON(或JSON克隆)作为传输媒体。


明年我看到AJAX / JSON共生使用的进一步发展,但它是因为b / ba
a限制路径AJAX同域限制。这使得在复杂的公司环境中使用它很难(b

甚至是域名)。此外,它不适用于服务器端免费RSS

Feed。在用户厌倦了这个之后:他们将继续使用某些跨域免费解决方案,如script.src(或其他)。

最初它会有点黑客攻击,但一旦获得足够的人气,它最终会被标记为标准。我接受下注

就2:1 :-)


AJAX的另一个重大影响是用户的力量演示

浏览器生产者和标准作者。有些浏览器不能/

多年来拒绝实施最基本的功能。更令人惊讶的是,它是全年观看他们如何急于实施,或者最近模仿XMLHttpRequest功能,以免失去他们的用户。并且

他们实际上*及时修复了所有错误*,有时在
月内!只是为了提醒谁是客户谁是卑微的

服务提供商 - 为此我们必须爱AJAX。


IMHO


Tony写道:

我想知道是否有人运行任何测试来比较解析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!



您可以考虑使用JSON而不是XML。


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


处理起来要好得多。

http://www.JSON.org


>与一个相当的碰撞旧讨论AJAX有什么问题:

< http://groups.google.com/group/comp.lang.javascript/browse_frm/thread...>


VK - 链接的thanx,但我没看到与我的特定

问题有关。我承认也许是密集的 - 如果我错过了,我会

欣赏一点方向:)

您可以考虑使用JSON而不是XML。 />
{" users":[" User 1"," User 2"," User 3"]}

处理起来要容易得多。




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

当下是执行的速度。


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

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


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!

解决方案


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


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


>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.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆