Reading Data From An XML File

M

mich

Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?


Thanks!!
 
T

Torsten Jenkner

mich said:
Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?


Thanks!!
The SAX parser is up to date and one of the current best parsing
solutions when XML streams are analyzed with saving heap.

http://sax.sourceforge.net/

regards

Torsten Jenkner
 
D

Daniel Pitts

Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?

Thanks!!


It depends on your need.
If you are fine with reading the whole XML file into memory, you can
use DocumentBuilder, and pass it the URL to your XML file, you'll get
back a Document object which implements the DOM.
 
J

jen.spinney

Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?

Thanks!!

It depends what you're doing with the XML. If you need simple, quick
processing go with SAX. If you want to build a tree structure of the
XML, check out JDOM.
 
M

mich

It depends what you're doing with the XML. If you need simple, quick
processing go with SAX. If you want to build a tree structure of the
XML, check out JDOM.


Thanks both, and it looks like I'll be going with SAX, since I'm only
reading the data. While the data will occasionally change I will just do it
manually.
 
J

JTL.zheng

Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?

Thanks!!

There three choices: SAX, DOM, JDOM

SAX: use less memory, faster, but not easy to use
DOM: use more menory as it reads all the XML tree when initialize,
easy to use
JDOM: use less menory and faster than DOM as it only reads which it
needs, and more easy to use
 
M

mich

JTL.zheng said:
There three choices: SAX, DOM, JDOM

SAX: use less memory, faster, but not easy to use
DOM: use more menory as it reads all the XML tree when initialize,
easy to use
JDOM: use less menory and faster than DOM as it only reads which it
needs, and more easy to use


Since I'm just going to be reading the XML file to get some data - no
updating - it should be better if create a singleton class to read it. The
XML file will hold product information, but since the business will not have
many products an XML file makes sence.

Another aspect that I'm looking at is simulating an index by giving a
different node name to each product, example below:

<catalog>
<largeWatermelon/>
<organicWatermelon/>
</catalog>

If the catalog gets too big I can also just have different XML files for
different produc groups, such as one file for vegetables, one for fruits,
 
L

Lew

JTL.zheng said:
There three choices: SAX, DOM, JDOM

SAX: use less memory, faster, but not easy to use
DOM: use more menory as it reads all the XML tree when initialize,
easy to use
JDOM: use less menory and faster than DOM as it only reads which it
needs, and more easy to use

Four: StAX.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top