newbie help for XML

R

Robert Karlsson

Hello,

I am in need to store data in files. I've
selected XML for this.

Basically the information will be stored in
the following way:

<stock>
<name></name>
<high></high>
<low></low>
..
<date></date>
</stock>
...
...

Due to the large amount of information
I am also concidering som kind of compression,
maybe using zip.

Basic functionality will be to write new entries,
change existing entries and search for specific entires.

However, I have noticed that there are
different APIs that I can use (SAX, DOM, JDOM).
I have done some work with SAX before but have
heard that DOM might be a better choice. What are
the pros and cons for each API?

Any help is appreciated.


Cheers,
Robert
 
S

sks

Robert Karlsson said:
Hello,

I am in need to store data in files. I've
selected XML for this.

Basically the information will be stored in
the following way:

<stock>
<name></name>
<high></high>
<low></low>
..
<date></date>
</stock>
..
..

Due to the large amount of information
I am also concidering som kind of compression,
maybe using zip.

Basic functionality will be to write new entries,
change existing entries and search for specific entires.

However, I have noticed that there are
different APIs that I can use (SAX, DOM, JDOM).
I have done some work with SAX before but have
heard that DOM might be a better choice. What are
the pros and cons for each API?

DOM loads the XML file first, SAX processes it as it loads it. When you're
creating an XML file that question is not relevant. JDom is just another API
that is more tailored to the idioms of Java.
 
M

Michael Borgwardt

Robert said:
Due to the large amount of information
I am also concidering som kind of compression,
maybe using zip.

Basic functionality will be to write new entries,
change existing entries and search for specific entires.

Flat XML files are just about the worst choice you could have
made then. Believe me, you'll be saving yourself a LOT of grief
if you use a proper databse instead. They're not nearly as
difficult to set up and use as people think.

A simple Java-based one like Hypersonic (www.hsqldb.org)
should be sufficient.
 
R

Robert Karlsson

[snip]
Flat XML files are just about the worst choice you could have
made then. Believe me, you'll be saving yourself a LOT of grief
if you use a proper databse instead. They're not nearly as
difficult to set up and use as people think.

A simple Java-based one like Hypersonic (www.hsqldb.org)
should be sufficient.

I agree with you that a database would be the most
appropriate solution looking at several aspects. Also
I have been using hsql before and liked it, I would
imagine that hsqldb has improved since.

I concidered using a database at first, but leaned
more to XML since I was afraid a database solution
could create more problems/work for the end user
while installing the software. Considering that my
targeted end users are mostly novice computer users.

An XML solution would require no extra tools/software
to be installed and run, which would reduce any amount
of errors with external software.

However, I'm talking only hypothetical not by experience.
Any thoughts are appreciated.


Cheers,
Robert
 
M

Michael Borgwardt

Robert said:
I concidered using a database at first, but leaned
more to XML since I was afraid a database solution
could create more problems/work for the end user
while installing the software. Considering that my
targeted end users are mostly novice computer users.

With hsqldb, there should be no need for any additional
installation. You can just bundle it as a library with your
program as long as you mention in the documentation
that the program is using it (I think that are the license
terms).

XML is absolutely not viable for storing large amounts of data
that changes. For every change you have to write the entire
file, and you could easily end up corrupting the data.
Furthermore, all searches are linear.
 
R

Robert Karlsson

[snip]
With hsqldb, there should be no need for any additional
installation. You can just bundle it as a library with your
program as long as you mention in the documentation
that the program is using it (I think that are the license
terms).

XML is absolutely not viable for storing large amounts of data
that changes. For every change you have to write the entire
file, and you could easily end up corrupting the data.
Furthermore, all searches are linear.

Thanks for the information Michael, you've (along with
Roedy's XML page at MindProd) convinced me to go for a
DB instead. I'll give hsqldb a try.

Thanks again!


..robert
 
D

Dale King

Hello, sks!
You said:
DOM loads the XML file first, SAX processes it as it loads it.

I would state it more that DOM builds an in-memory model as it
loads the file. While it provides a default representation, you
have complete control over the representation. Saying that it
loads the XML can lead someone to the false conclusion that the
amount of memory taken will be as big as the XML file. But I'll
address that in another thread.
When you're
creating an XML file that question is not relevant. JDom is just another API
that is more tailored to the idioms of Java.

And I recommend you try XOM which is a better replacement for
JDOM to overcome manyof its shortcomings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top