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 / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

parsing XML files with SAX

Thread view: 
mike henkins - 23 Jul 2005 22:22 GMT
hi,

I've been looking through the various XML parsers API available and I have
decided to use the SAX parser. Probably not the best of choices but I think
it can do the job. What is the best way to parse an XML file using the SAX
parser ? I have seen examples where they store each element tag in java bean
classes. I am not sure this is a good way for my XML file which looks like
this:

<parent>
<node1>
<child1>AAA</child1>
<grandchild1>BBB</grandchild1>
<grandchild2>
<anything>CCC</anything>
</grandchild2>
<child2>DDD<</child2>
<child3>DDD<</child3>
</node1>
<node2>
<child1>AAA<</child1>
<grandchild1>BBB</grandchild1>
<grandchild2>
<anything>CCC</anything>
</grandchild2>
<child2>DDD<</child2>
<child3>DDD<</child3>
</node2>
</parent>

I have to get the value of the tag "anything" in node1, node2 etc ..., store
the value of child3 in a database etc ...

Does anyone have any experience or advices regarding the fastest way to do
that using SAX (or any other parser) ?

Thanks !
HalcyonWild - 12 Aug 2005 20:09 GMT
Use DOM. It maps our thinking about XML better. You can visualize the
tree with DOM. A bit slower, but its OK. Probably, your DB insert code
will take the longest time.
hawat.thufir@gmail.com - 12 Aug 2005 22:35 GMT
...
> I have to get the value of the tag "anything" in node1, node2 etc ..., store
> the value of child3 in a database etc ...
[quoted text clipped - 3 lines]
>
> Thanks !

What's meant by "fast"?  Fastest development or fastest execution?

I'm reading chapters 5-6 of
<http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html>.  I believe
that SAX <http://www.saxproject.org/> has a faster developement.
There's also JDOM <http://www.jdom.org/> and DOM4j
<http://www.dom4j.org/>.

DOM is designed to work with a variety of languages, such as Perl,
which can be a downside if you're doing everything else in Java, I
would think.

I'd be very interested in how you're going to do your db insertions,
and which database you select :)

-Thufir


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.