Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to read XML data and store in List<List<Object>> using Java

 
Gaurav Kr. Arora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to read XML data (big XML file) and store in List<List<Object>> using Java APIs. I am familiar with DOM and SAX parsers. Have heard of JAXB technique.

Could you please let me know the best way to do it?

If there is any other way apart from the ones listed above, please suggest.

Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Exactly what kind of values are you extracting from the XML? Complex structure or simple strings...
2. Do you already have some Java objects that need to be populated with data from the XML?
3. What do you need to do with this List after the data is stored?
4. How large is the XML document roughly?

Bill
 
Gaurav Kr. Arora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Exactly what kind of values are you extracting from the XML? Complex structure or simple strings... Simple strings
2. Do you already have some Java objects that need to be populated with data from the XML? No, we have to create List<List<Object>>
3. What do you need to do with this List after the data is stored? Some validations based on rules.We will be iterating through List<List<Object>> and verifying if data is in correct format or not.
4. How large is the XML document roughly? Around 40 mb

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extracting Strings from a simple XML structure sounds like you could use SAX or StaX parsing, which avoids creating a big DOM in memory and will be surprisingly fast.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic