怎样提高xml的查询效率??

wuqiuzi 2002-05-24 12:14:01
现在有一个xml文件,他的结构如下所示:
存储了99999个用户的基本信息
<?xml version="1.0" encoding="UTF-8"?>
<ACL>
<object id=001 >
<user>
<name>abc</name>
<method>operation1,operation2</method>
</user>
........
<user>
<name>abc1</name>
<method>operation1,operation2</method>
</user>

</object>
<object id=9999>
....
</object>

</ACL>

我现在想以最快的速度获得特定object里某个用户的方法,比如id为001中用户 abc的方法。
我可以用sax遍历得到,但是实现起来感觉比较笨。而且这是一种顺序查找的方式
如果我有序排列所有的记录,那么怎样采用类式于2分法这类效率比较高的方法?
有现成的标准支持吗?
...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2002-05-24
  • 打赏
  • 举报
回复
for speed, SAX is your best choice, otherwise, you'd better move back your data to a database

throwing an exception to stop the parsing is recommended by the documentation for XMLReader.parse() method:

This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.

http://xml.apache.org/xalan-j/apidocs/org/xml/sax/XMLReader.html

wuqiuzi 2002-05-24
  • 打赏
  • 举报
回复
还有在sax中,如果我找到了记录,那么剩下的记录就可以不继续遍历下去了。怎么结束遍历啊?我用的是在java中抛出一个异常,有没有别的更好好的解决方式?

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧