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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.