O**n 发帖数: 133 | 1 google了一下,发现java有DOM, 还有一种叫SAX的。据说DOM不好。
哪位大虾介绍一下吧,他们有什么区别呢?
如果我想用来parse一个巨大的xml的file, ~500MByte,
应该用哪一个?怎么用呢?
//bow
多谢! | st 发帖数: 1685 | 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 : 多谢!
| e***g 发帖数: 158 | 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 : 多谢!
| g*s 发帖数: 2277 | 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.
| e***g 发帖数: 158 | 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.
| g*s 发帖数: 2277 | 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.
| w********c 发帖数: 2632 | 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.
| m**c 发帖数: 90 | 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.
|
|