Sencha Touch - 大 XML 文件问题
我正在通过互联网从 xml 文件中读取内容!
该文件包含大约 10000 个 xml 元素,并加载到一个列表中(每个元素一张图片和标题)! 这会极大地减慢应用程序的速度!
有没有办法加快这个速度? 也许用选择命令?
有一些示例或教程吗?
I am reading the content out from a xml file over the internet!
The file contains about 10000 xml-elements and is loaded into a list (one picture and headline for each element)!
This slows down the app extremly!
Is there a way to speed this up?
Maybe with a select-command?
Are there some examples or tutorials out there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你运气不好,无法得到简单直接的答案。
如果您控制 XML 文件的来源服务器,则应该对其进行更改以支持结果分页,而不是发送完整的文档。
如果您不控制服务器,则可以设置一个服务器来代理结果并在服务器端对应用程序进行分页。
最后一个选项是以块的形式处理文件。这意味着处理文本的子字符串。只需获取前 x 个字符的子字符串,对其进行解析,然后对结果进行处理。如果您需要更多,您将处理接下来的 x 个字符。这可能会很快变得非常混乱(因为 XML 并不能真正以这种方式很好地解析),并且仅下载包含 10k 元素的文档并将其加载到内存中可能会很费力/缓慢/昂贵(如果通过 3G 连接下载)对于移动设备。
You are out of luck for a easy-straight forward answer.
If you control the server that the XML file is coming from, you should make the changes on it to support pagination of the results instead of sending the complete document.
If you don't control the server, you could set up one to proxy the results and do the pagination for the application on the server side.
The last option is the process the file in chunks. This would mean, processing sub-strings of the text. Just take a sub-string of the first x characters, parse it and then do something with the results. If you needed more you would process the next x characters. This could get very messy fast (as XML doesn't really parse nicely in this manner) and just downloading a document with 10k elements and loading it into memory is probably going to be taxing/slow/expensive (if downloading over a 3G connection) for mobile devices.