 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
mike henkins Guest
|
Posted: Sat Jul 23, 2005 9:22 pm Post subject: parsing XML files with SAX |
|
|
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<
<child3>DDD<
</node1>
<node2>
<child1>AAA<
<grandchild1>BBB</grandchild1>
<grandchild2>
<anything>CCC</anything>
</grandchild2>
<child2>DDD<
<child3>DDD<
</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 !
|
|
| Back to top |
|
 |
HalcyonWild Guest
|
Posted: Fri Aug 12, 2005 7:09 pm Post subject: Re: parsing XML files with SAX |
|
|
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.
|
|
| Back to top |
|
 |
hawat.thufir@gmail.com Guest
|
Posted: Fri Aug 12, 2005 9:35 pm Post subject: Re: parsing XML files with SAX |
|
|
mike henkins wrote:
....
| Quote: | 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 !
|
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
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|