• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Which parser to choose ?

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want read following XML file

<bottombar>
<height></height>
<width></width>
<background>
<color></color>
<imagepath></imagepath>
</background>
</bottombar>

<buttons>
<state name="radio">
<button>
<xcoordinate></xcoordinate>
<ycoordinate></ycoordinate>
<normalimage></normalimage>
<pressedimage></pressedimage>
<timer></timer>
<action></action>
</button>
</state>
</buttons>

I want read this file, there can be N numbers of <button>tag
I have some knowledge of SAX and DOM parser....but I'm not able to choose which is better one...
There is also new parser as JDOM....
now I have 3 options as SAX,DOM, JDOM
please help me to choose better parser for my application

thanks in advance
Swapnel
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swapnel,

there are even more options like JAXB or StAX to process XML documents in Java

Which parser to choose really depends on which task to solve! It may be for example a trade-off between memory consumption or performance. This may depend on your requirements, the size of XML documents etc. Without knowing more about these things it's difficult to choose the "right" API. Perhaps you can elaborate a little bit more on this!

Marco
 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The contents of the file are mentioned above.... file is not going to be a large one....
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At least this doesn't limit you to "memory efficient" APIs. Nevertheless the appropriate API in your case depends on what you're trying to achieve.

Basically there are two different things the APIs do when reading XML documents: One class of APIs transforms you XML document into an in-memory object representation (DOM, JAXB). The other generate some kind of "events" for nodes and attributes in the XML document which let's you invoke some action for each event.

There is surely a lot more to all the major XML APIs but perhaps this helps you to make a decision. If you have more question, just feel free to ask ;-)

Marco
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The prvious post is 100% right. I would add that starting with JDOM is a little more easy because it brings to the machine the same representation that is in your brain
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!