avatar
Java XML parser的问题# Java - 爪哇娇娃
O*n
1
google了一下,发现java有DOM, 还有一种叫SAX的。据说DOM不好。
哪位大虾介绍一下吧,他们有什么区别呢?
如果我想用来parse一个巨大的xml的file, ~500MByte,
应该用哪一个?怎么用呢?
//bow
多谢!
avatar
st
2
use SAX, which is single parse without building up the tree structure,
500M xml probably will bring DOM... (not enough memory)...
also, there are many many versions of DOM, SAX for java, check them
yourself. :D

【在 O**n 的大作中提到】
: google了一下,发现java有DOM, 还有一种叫SAX的。据说DOM不好。
: 哪位大虾介绍一下吧,他们有什么区别呢?
: 如果我想用来parse一个巨大的xml的file, ~500MByte,
: 应该用哪一个?怎么用呢?
: //bow
: 多谢!

avatar
e*g
3
depends on what you want to do after parse. don't use SAX unless you
have to, it's more work.

【在 O**n 的大作中提到】
: google了一下,发现java有DOM, 还有一种叫SAX的。据说DOM不好。
: 哪位大虾介绍一下吧,他们有什么区别呢?
: 如果我想用来parse一个巨大的xml的file, ~500MByte,
: 应该用哪一个?怎么用呢?
: //bow
: 多谢!

avatar
g*s
4
or use JAXB to get flexibility of DOM and performance of SAX.

【在 e***g 的大作中提到】
: depends on what you want to do after parse. don't use SAX unless you
: have to, it's more work.

avatar
e*g
5
is it mature/popular yet? haven't heard of it for a while.
well it may not fit, if he wants to search by xpath, or to modify xml.
there's is no THE solution, it depends on what he wants to do.

【在 g*s 的大作中提到】
: or use JAXB to get flexibility of DOM and performance of SAX.
avatar
g*s
6
still not mature? I used it two years ago for content conversion. did not
pay attention afterwards.hehe

【在 e***g 的大作中提到】
: is it mature/popular yet? haven't heard of it for a while.
: well it may not fit, if he wants to search by xpath, or to modify xml.
: there's is no THE solution, it depends on what he wants to do.

avatar
w*c
7
It's an issue of the context. SAX is used for simplicity and speed, while DOM
is used for flexibility. If ur source is scanned only once, which is true in
most massive data processing, SAX is good enuf.

【在 e***g 的大作中提到】
: depends on what you want to do after parse. don't use SAX unless you
: have to, it's more work.

avatar
m*c
8

In general, if you are going to manipulate XML, you probably want to use DOM
so that you can insert/delete/update node in the DOM tree. If you are going
to parse XML only without any manipulation, you can use either DOM or SAX, but
SAX is faster comparing to DOM and uses less memory. In your case, you may
have to use SAX unless you have a lot memory.
DOM

【在 w********c 的大作中提到】
: It's an issue of the context. SAX is used for simplicity and speed, while DOM
: is used for flexibility. If ur source is scanned only once, which is true in
: most massive data processing, SAX is good enuf.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。