aspose file tools*
The moose likes XML and Related Technologies and the fly likes Which one is the best XML parser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Which one is the best XML parser?" Watch "Which one is the best XML parser?" New topic
Author

Which one is the best XML parser?

Anthony Kwok
Greenhorn

Joined: May 09, 2001
Posts: 23
Hi,
My application need to read some parameter file in XML format. Can some one suggest me a very fast and small footprint parser?
Thanks
Anthony
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
I'm just starting to learn XML. I am also interested in what would be a good parser to start off with.
subramaniam vaidyanathan
Greenhorn

Joined: Jun 25, 2001
Posts: 10
I started with Crimson parser which is the parser from Sun. It is a packaged with the JAXP (Java Api for Xml Parsing) download from sun. It is free and fast. XP is another good parser that I've used. If you're starting with Xml using Java, then I would recommend Crimson.
Originally posted by Stanley Tan:
I'm just starting to learn XML. I am also interested in what would be a good parser to start off with.

sheetal bhandari
Greenhorn

Joined: Aug 26, 2001
Posts: 4
Hi all
Working with "xerces" parser will be great.It is freely available at apache site.It gives great performance.Just go for it!!!

------------------
Anthony Kwok
Greenhorn

Joined: May 09, 2001
Posts: 23
As Sun already launch the 'official' API for XML. Should I make use of it or other third parties XML parser? I heard that there is non-validate one named 'Lighting' which is very fast and small memory consumption. Anyone use this one can share experience with us?
Thanks
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
Are you looking for a DOM or SAX parser..
I was recently recommended JDOM for our project. I dont know details about JDOM but it is supposed to be easier to use then
sun JAXP. I have written a properties file reader using JAXP but sometimes I find JAXP to be cumbersome and an API with higher level constructs is definitely required. And I suppose JDOM is supposed to do that.
Tom Ben
Ranch Hand

Joined: Aug 17, 2001
Posts: 109
I have justed finished a project using JAXP and loved it. I used the DOM parser and it works great have never really had a problem with it. The other end of the project is using Xerces and they found it to be easy to use as well.


Sun Certified Programmer on the Java 2 Platform
Yoo-Jin Lee
Ranch Hand

Joined: Nov 01, 2000
Posts: 119
Hi,
Aelfred is an excellent SAX paser with a small memory footprint and is very fast. It's really good for applets. It's written by the foremost figure in SAX, David Megginson.
-info from Professional Java XML.
You can download it from http://www.opentext.com/services/content_management_services/xml_sgml_solutions.html#aelfred_and_sax
Professional Java XML is awesome! I recommend everyone to get it.
hope this helps,
Yoo-Jin.
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
I really like sun's xml parser.. It is easy to use.
Originally posted by Anthony Kwok:
Hi,
My application need to read some parameter file in XML format. Can some one suggest me a very fast and small footprint parser?
Thanks
Anthony

Paul Jenkins
Greenhorn

Joined: Aug 21, 2001
Posts: 9
try http://www.themindelectric.com , good one there as well.
paul
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Time out!
A lot of you have given many different answers and now I'm spinning! I've heard of Xerces a lot but not of Crimson. Is Crimson the reference implementation of an XML parser by Sun? What do you mean it is packaged with the JAXP? So JAXP isn't an XML parser but a package?
Mohit Joshi: You used a lot of acronyms. Care sharing what they all mean? What is DOM/SAX and their difference?
Last question: Does all this come with JDK1.3 or J2EE1.2.1 ?
Phew!
Bhavesh Patel
Greenhorn

Joined: May 25, 2001
Posts: 3
I would suggest the use of IBM VisualAge for Java with IBM Sax Parser. VAJ comes with some basic tutorials about how to start using SAX and create some reader classes.
And yes, SAX is always the best choice for starters on XML. cause its less complex and easy to learn. So whether you use VAJ or not, but start with SAX Parsers(Xerces or IBM) to learn XML. And you might find many good tutorials on net to do that.
refer these as some of the useful links
http://www.xmldir.com/default.asp
http://www.itworld.com/nl/java_tut/01312001/
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
a Dom parser keeps the tree structure of xml ( along with the Data) in memory, so modifying the structure / Data is easy and can be done as many times as required.
A SAX parser reads the XML but doesnt keep the structure / Data in memory, instead it passes on the information to listeners which can then either create their own tree for manipulation ( the listener can be a DOM parser for example). Usually SAX parser is used in rare situations where performance is very important.
I am sure you can find a lot of information about this on the net / javaranch itself.
jeremy crosbie
Greenhorn

Joined: Jun 20, 2001
Posts: 23
Originally posted by Anthony Kwok:
Hi,
My application need to read some parameter file in XML format. Can some one suggest me a very fast and small footprint parser?
Thanks
Anthony


Your first choice has to be whether you want a DOM or SAX parser. Since it sounds like memory is at a premium, we will assume you want to use SAX.
Many a SAX parser is available, but the smaller they get the more lax they become with implementing XML standards and features, such as validation. Here are a few to look at:
- aelfred: http://www.opentext.com/services/content_management_services/xml_sgml_solutions.html#aelfred_and_sax
- MinML: http://www.wilson.co.uk/xml/minml.htm
- kXML: http://kxml.enhydra.org/
These last two were intended primarily for embedded devices (cell phones) as they consume very little memory. Hopefully one of these will fit your needs.
------------------
Jeremy Crosbie
Co-Author of Professional Java XML


Jeremy Crosbie<BR>Co-Author of <A HREF="http://www.amazon.com/exec/obidos/ASIN/186100401X/ref=ase_electricporkchop" TARGET=_blank rel="nofollow">Professional Java XML</A>
Swami Iyer
Greenhorn

Joined: Aug 17, 2001
Posts: 1
I would recommend JDOM, I have been using it for past one year and it is becoming a Java standard.
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
Hello Swami,
Since you have been using JDOM for some time, can you give feedback about how it compares with JAXP. I have to decide whether to migrage an entire project from JAXP to JDOM and I should know if it is worth it..
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Thank you for the clarification between DOM and SAX XML parsers. My first question still stands. What is JAXP? And what is JDOM? Thank you.
Kris Decker
Ranch Hand

Joined: Jul 25, 2001
Posts: 38
JAXP == Sun's Java APIs for XML Pasing http://java.sun.com/xml/xml_jaxp.html
JDOM ==
...a complete, Java-based solution for accessing, manipulating, and outputting XML data from Java code...
http://www.jdom.org/
Originally posted by Stanley Tan:
Thank you for the clarification between DOM and SAX XML parsers. My first question still stands. What is JAXP? And what is JDOM? Thank you.


[This message has been edited by Kris Decker (edited August 28, 2001).]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
SAX and DOM are programming language neutral specifications by W3C. Xerces (the sax parser of apache) for example is available for both Java and C++. Obviously this is an advantage if you have to work with more than one language.
On the other hand the APIs are restricted in using java specific constructs for the same reason. Here JDom comes into play: It is designed to *not* necessarily conform to the W3C standards but to provide an API that feels much more natural to Java developers; for example it uses the Collections API of Java 2.
I would go with JDom in most cases.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Wendal Park
Ranch Hand

Joined: Aug 28, 2001
Posts: 39
For line-by-line parsing, I would strongest suggest Apache's Xerces.
Here's my thought about choosing XML parsers: Try to go to some big companies (esp. the E-Commerce ones) sites like Commerce-One and see if they have their own XML DTDs as "standard". If so, then they would have probably tested them out with some parsers out in the market. Then you'll see which one is more "familiar" and should start to learn first.
KMWorld


MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Thank you for the replies. There are so many things on xml.apache.org. I should get Xerces and start from there? Would that be advisable for a beginner? Someone said that it was limiting? How limiting is that? (Will it be enough for beginning XML?)
And what is Xalan?
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
JDOM is lightweight which need a parser and a tranformer work behind it. You can use either xerces or crimson as its parser, xalan or saxon as its tranformer.
We just switched from jaxp1.0 to jaxp1.1, from xerces to crimson, from xalan from saxon. Adopt JDOM in our new code.
Thanks!
Roseanne
Join our Study Group when certified

[This message has been edited by Roseanne Zhang (edited August 28, 2001).]
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
What do you mean by lightweight (or small footprint?) Does that mean it takes up little memory?
I still don't get it. What is the difference between these:
jaxp1.0 to jaxp1.1, from xerces to crimson, from xalan from saxon
? JAXP is the API (like javax.swing?)
Xerces/Crimson is the XML parser ?
What is Xalan/Saxon
How do they all converge into the big picture? Thanks
Abhijit Kulkarni
Greenhorn

Joined: Dec 03, 2000
Posts: 23
I used the JAXP parser. As a beginer, I feel that it is not diffucult to use or get a particular parser. But rather it is more diffcult to find out how to use a particular parser with suitable examples such that they satisfy your needs in the initial stage.
I found it eaisest to begin with the sun's JAXP parser.
Hope standardisation and secifications would cause more ease in programming practices.

------------------
abhijit from pune.
Ability alone is not enough for success,it must be sparked by ambition and sustained with determination


<b><i>Abhijit</i></b> <br />---------------------------------<br />Give me my share of smile!
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
I am sorry. I am beginner too. I thought JAXP was not a parser and that it was a framework so that I could use any parser in my application. Someone please clarify my doubts. Thank you.
Originally posted by Abhijit Kulkarni:
I used the JAXP parser. As a beginer, I feel that it is not diffucult to use or get a particular parser. But rather it is more diffcult to find out how to use a particular parser with suitable examples such that they satisfy your needs in the initial stage.
I found it eaisest to begin with the sun's JAXP parser.
Hope standardisation and secifications would cause more ease in programming practices.


L Goundalkar
Ranch Hand

Joined: Jul 05, 2001
Posts: 395
Hi all,
Hope this URL helps.
http://www.xml-zone.com/articles/pm020101/pm020101-1.asp
TIA
------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform


SCJP, SCWCD
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Thanks for the link. The more I read, the more I'm learning about XML. The article refers to JAXP as Sun's XML parser and not an XML framework. So I guess it is a parser after all. It's quite surprising Microsoft's parser is so fast. Is that what .NET uses?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Xalan and Saxon are both XSL-Processors. See http://www.w3schools.com/xsl/
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
I do find it strange that microsoft parser is faster then the others by a factor of 10(according to above article). This indicates that the basic process of parsing would be different for microsoft parser. Unfortunately no one can find out because of their propriety code..
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Ok, I think I got it. XSL is used to transform XML into HTML and XSL uses XSLT to do the transforming. Correct?
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Hi, I'm reading one of the articles provided in the links and came across a statement that said that XML is a metalanguage - a language used to define new markup languages. What does this mean? I can create my own version of HTML?
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
Well Stanley, you sure are learning fast..
1) XSL is used to transfrom xml into html. True. But remember that html is also XML ( if it is well formed ). so a more generic description would be XSL is used to transform xml in to another xml( which could be html).
2)XSL uses XSLT to do transformation. If I am correct ( and that is a big question ) XSL can be viewed as combination of XSLT and XPath. The XSLT is for XSL(Transformation). So you can say that XSL engines use XSL to do transformation. XSL and XSLT are sometimes used interchangably so you can say XSLT engines use XSLT to do transformation.
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Thank you for your reply. I think I'll be dreaming about Xs tonight.
HTML is also XML - is this XHTML or is that another issue all together?
Originally posted by mohit joshi:
Well Stanley, you sure are learning fast..
1) XSL is used to transfrom xml into html. True. But remember that html is also XML ( if it is well formed ). so a more generic description would be XSL is used to transform xml in to another xml( which could be html).
2)XSL uses XSLT to do transformation. If I am correct ( and that is a big question ) XSL can be viewed as combination of XSLT and XPath. The XSLT is for XSL(Transformation). So you can say that XSL engines use XSL to do transformation. XSL and XSLT are sometimes used interchangably so you can say XSLT engines use XSLT to do transformation.

Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
In the course of reading one of the superly abundant articles and links from Javaranch, I have learned that there are two types of XML parsers - validating and non-validating. What type are the XML parsers described in this thread?
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
JAXP is API, mostly are definition of a bunch of interfaces. You can use any parse implements those interfaces.
The above mentioned so-called JAXP parser is crimson which shipped with JAXP, but actually is not part of JAXP. You can use other parser instead. Crimson was SUN's reference implementation of JAXP parser, and now Sun donated it to Apache group.
JDOM is a set of API too, but they are concrete classes, which uses any JAXP parser. When you download JDOM, we will get a crimson and/or xerces parser with it. However, they are actually not part of JDOM. JDOM uses them.
I hope I make myself clear a little bit.
Roseanne
 
jQuery in Action, 2nd edition
 
subject: Which one is the best XML parser?