8

I am using XStream to convert XML to objects. I am converting large xml. I have encountered below two statements.

XStream xstream = new XStream(new DomDriver());

XStream xstream = new XStream(new StaxDriver());

Since I am using large xml for conversion, which one result better performance? why?

Please help.

Java P
  • 2,241
  • 6
  • 31
  • 45

2 Answers2

4

Staxdriver should perform better as it uses pull parser technology which is the fastest technology for parsing xml and uses less memory as document is not loaded in memory as for dom one.

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • By default XStream uses XppDriver which also uses pull parser. In my tests on a real production data StaxDriver is about 10% slower that default XStream's XppDriver on serialization and deserialization. – Sergio Jul 05 '15 at 10:47
2

The StaxDriver will parse the data progressively so it can be more efficient. It only work with Stax parsers. If you want to use a DOM parser, you need to use the DomParser.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130