I am currently using native Java XML processing library (Xerces). I can’t use any sax parser because I need random access to xml nodes. I am finding that CPU usage goes 100% when I am parsing XML files. There are large number of small size (1-10kb) that I am processing like this-
while(hasFile){
processXMlfile(hasFile.next);
}
In processXMlfile() I am building parsing and processing file.
If I move to JDOM library, will I gain any performance benefit?
The bottleneck is probably XML parsing, and JDOM will likely use the same XML parser under the covers, so it won’t make any difference.
A key factor when you are parsing lots of small files is to avoid the parser initialization costs. Reuse the same XML parser instance for all the files.