Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Storing data from a XML file for processing

Posted on 2003-03-03
4
Medium Priority
?
220 Views
Last Modified: 2010-03-31
Hello,

     I am getting some data in VOTable form or equivalent to XML form, using SAVOT parser, the file is parsed and it is getting printed on the console.

The data is in the form of tables where the rows contains the Name = value pair data.

i want to store these values and later retrieve them for further processing. the data varies depending on the query, sometimes there are many number of tables, and all the data has to be stored .

I am planning to use JTable,

Is there any other way to achieve the above,

thanks & regards
0
Comment
Question by:alpjose
4 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 8063217
If all the rows are just a name and value pair then you could use classes that are designed for holding information like this, like HashTable or Properties, or even just a simple Array.

The main issue is whether the name part of the name value pair will be unique.

When you say you want to "store" them do you mean just hold them or actually persist/write them to disk ?

Also, unless you want to display the data in a graphical Table then JTable is probably overkill. You could just use a TableModel (the underlying storage class of JTable)if all you want to do is hold the data.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8063313
If you can, and are, going to use a table-like structure in which to store the name value pairs, then of course the name will be redundant for storage purposes as it will represent a column name.

How are the name\value pairs returned - as a String? As in:

key=value
0
 

Accepted Solution

by:
doddjames earned 120 total points
ID: 8081595

Use an XML document, parse it into a DOM tree, then do XPath queries on the Document.

You can do this using dom4j (www.dom4j.org) in about 3 lines.

  SAXReader reader = new SAXReader();
  Document document = reader.read( input );
  Element selected = (Element) document.selectSingleNode( "/my/query[@name='blah']" );
  String answer = selected.getText();

Very simple.
0
 

Author Comment

by:alpjose
ID: 8243146
Thanks doddjames , it is working.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question