Browse DevX
Sign up for e-mail newsletters from DevX


Choose Your Java XML Parser  : Page 4

Parsers differ significantly in performance, reliability, and conformance to standards. This article compares the Xerces, Oracle and Sun parsers.


Conformance and Performance
An XML parser is an essential tool for any serious programming effort involving XML documents. The parser is the link between the XML document representing data and the application code. Conformance to the W3C standards varies widely between the parsers, but it's beyond the scope of this article to assess how well each parser conforms to the standards.

Using a very informal method, I timed each parser as it went through a 92KB XML file. The system was a Windows NT 4 SP6 running on a 300 MGHz Pentium machine with 64MB of memory. I used Java's System.currentTimeMillis() method to see how long it took the program to perform the parse() method. The result ranked Oracle's parser as the fastest, followed by JAXP and Xerces. Again, this was a very unscientific test, so your results may vary.

Additionally, I tried the XML parser from Microsoft using a VB program. The parser was very fast. You should seriously consider the Microsoft XML parser for windows-only applications as its performance is far superior to all the Java parsers discussed in this article.

Table 1: Average parser load times
Parser Avg. Parse Time
(in milliseconds)
Oracle Parser 1094
Sun Parser (JAXP) 1344
Xerces 1719
Microsoft Parser 80

As XML technologies mature, we probably will see less direct interaction with the parser. Also, as parsers move toward full compliance with the standards, it will be relatively easy to change parsers, especially when using factory classes. Performance, reliability, and the programmers' familiarity with a particular implementation are going to be the most important factors in deciding which parser to use.

Piroz Mohseni is President of Bita Technologies, focusing on business improvement through specialized training and effective usage of technology. His areas of interest include enterprise Java, XML, and mobile applications.
Thanks for your registration, follow us on our social networks to keep up-to-date