Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Reading Data From An XML File (http://www.velocityreviews.com/forums/t525320-reading-data-from-an-xml-file.html)

mich 07-27-2007 11:27 PM

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


Thanks!!



Torsten Jenkner 07-27-2007 11:56 PM

Re: Reading Data From An XML File
 
mich schrieb:
> 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

Daniel Pitts 07-28-2007 03:02 AM

Re: Reading Data From An XML File
 
On Jul 27, 4:27 pm, "mich" <s...@doo.what> wrote:
> 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.


jen.spinney@gmail.com 07-28-2007 03:31 AM

Re: Reading Data From An XML File
 
On Jul 27, 7:27 pm, "mich" <s...@doo.what> wrote:
> 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.


mich 07-28-2007 04:00 AM

Re: Reading Data From An XML File
 

<jen.spinney@gmail.com> wrote in message
news:1185593512.155533.262470@19g2000hsx.googlegro ups.com...
> On Jul 27, 7:27 pm, "mich" <s...@doo.what> wrote:
>> 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.



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.



JTL.zheng 07-28-2007 06:22 AM

Re: Reading Data From An XML File
 
On Jul 28, 7:27 am, "mich" <s...@doo.what> wrote:
> 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


Roedy Green 07-28-2007 08:24 AM

Re: Reading Data From An XML File
 
>Since this obviously changes over time what is currently the most effective
>way to read parts of am XML file?

See http://mindprod.com/jgloss/xml.html
for your options. You DON'T have to write your own parser. Java has
them built in now.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

mich 07-28-2007 12:28 PM

Re: Reading Data From An XML File
 

"JTL.zheng" <jtl.zheng@gmail.com> wrote in message
news:1185603742.486068.168650@m37g2000prh.googlegr oups.com...
> On Jul 28, 7:27 am, "mich" <s...@doo.what> wrote:
>> 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



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,



Lew 07-28-2007 01:18 PM

Re: Reading Data From An XML File
 
JTL.zheng wrote:
> On Jul 28, 7:27 am, "mich" <s...@doo.what> wrote:
>> 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


Four: StAX.

--
Lew


All times are GMT. The time now is 01:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.