Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Reading Data  From An XML File

Thread view: 
mich - 28 Jul 2007 00:27 GMT
Since this obviously changes over time what is currently the most effective
way to read parts of am XML file?

Thanks!!
Torsten Jenkner - 28 Jul 2007 00:56 GMT
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 - 28 Jul 2007 04:02 GMT
> 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 - 28 Jul 2007 04:31 GMT
> 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 - 28 Jul 2007 05:00 GMT
>> Since this obviously changes over time what is currently the most
>> effective
[quoted text clipped - 5 lines]
> 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 - 28 Jul 2007 07:22 GMT
> 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
mich - 28 Jul 2007 13:28 GMT
>> Since this obviously changes over time what is currently the most
>> effective
[quoted text clipped - 9 lines]
> 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 - 28 Jul 2007 14:18 GMT
>> Since this obviously changes over time what is currently the most effective
>> way to read parts of am XML file?
[quoted text clipped - 8 lines]
> JDOM: use less menory and faster than DOM as it only reads which it
> needs, and more easy to use

Four: StAX.

Signature

Lew

Roedy Green - 28 Jul 2007 09:24 GMT
>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.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.