I have a XML file with many copies of table node structure as below:
As it is not an efficient manner to traverse the file for each time to fetch the details of each node for the queries in the program, I used the nested hashmap concept to store the details while traversing the XML file for the first time. The structure I used is as below:
But the problem I’m facing now is regarding retrieving the Value part using the nested Keys.
For example, If I need the value of Slno Key, I have to specify TblID, SelectColumns, Slno in nested form like:
This is unconvinent to use in a program. Please suggest a solution but don’t tell that iterators are available. As I’ve to fetch the individual value from the map according to the need of my program.
Thanks in advance,
You could use XPath expressions to traverse the DOM directly. However if your desire to avoid processing the DOM repeatedly is based in reality, and is not just premature optimization based on guesswork or rumours, and you don't like the programming you have let yourself in for, then you're going to have to change your data structure.
Which of course was your question -- how should you change it? Well, no serious designer would create a design based on a single sample of its input. So you're going to have to explain a bit more about the structure of the documents you expect to process.
Joined: Apr 24, 2011
The structure of my file is same as the structure of the single table node that I've written above. The table node repeats depending on as many departments have the mail details in the database, that is mail details table for each department is separate. So the table node repeats as the column names of each table are different.
The purpose of XML file is to store the column name information of each table associated with table name and its ID and to serve as an input to the query statements.
I'm not using the entire information of the XML in my queries. I'm first checking which of the department have the privilege to send mails and collecting their IDs. Then I've to match the IDs that is in my XML and then only the column name information of those department is fetched from my XML. This is all about my program.