tags:

views:

23

answers:

1

Hi Guys,

I am trying to Cache a XML File on application initialization. What would be the best approach to do it?

Which would be the most efficent datastructure which I can use? The datastructure should be efficent in lookups.

Thanks!

+1  A: 

I assume that you want to cache the contents of the XML file, and not a reference to the file. You would first parse the XML, and then you could go a couple of ways. One way to do this would be to map the XML to a (object tree of) Java class, and then cache the Java class. You can use Castor or some JAXB library to do this. If your XML has a set of repeating nodes, you can consider an in-memory database to query on, such as HyperSQL. HyperSQL would allow you to use plain SQL for lookups.

Sualeh Fatehi