Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XOM v/s javax.xml.parsers

Tags:

java

xml

xom

i want to do read simple XML file .i found Simple way to do Xml in Java

There are also several parsers available just wanted to make sure that what are the advantages of using XOM parser over suns parser

Any suggestions?

like image 558
anish Avatar asked Dec 22 '22 10:12

anish


2 Answers

XOM is extremely quick compared to the standard W3C DOM. If that's your priority, there's none better.

However, it's still a DOM-type API, and so it's not memory efficient. It's not a replacement for SAX or STAX.

like image 172
skaffman Avatar answered Dec 31 '22 07:12

skaffman


You might want to check this question about the best XML library and its top (XOM) answer; lots of details about advantages of XOM. (Leave a comment if something is unclear; Peter Štibraný seems to know XOM inside and out.)

As mentioned, XOM is very quick and simple in most tasks compared to standard javax.xml. For examples, see this post in a question about the simplest way to read in an XML file in Java. I collected some nice examples that make XOM look pretty good (and javax.xml rather clumsy) there. :-)

So personally I've come to like XOM after evaluating (as you can see in the linked posts); for any new Java project I'd most likely choose XOM for XML handling. The only shortcoming I've found is that it doesn't directly support streaming XML (unlike dom4j where I'm coming from), but with a simple workaround it can stream just fine.

like image 45
Jonik Avatar answered Dec 31 '22 07:12

Jonik