问题
I am currently developing an RSS feed reader, and I am wondering which XML parsing API would be the best fit for that. (Please note that I am not looking for a Feed parser library - it is merely the starting point for that research about XML APIs)
I am looking for a rundown of the various XML parsing APIs on the Java platform, focusing on the following criteria:
- Ease of configuration
- Is the configuration in a separate file?
- Are there reasonable defaults?
- Ease of use
- Node navigation - to siblings, to children, to the parent.
- Access/Manipulation of Namespaces, Attributes, Text.
- Is the class hierarchy well-thought or natural?
- Invalid XML - what happens (when does it fail?), and what can I do when:
- an invalid character is encountered (forbidden in either the encoding or the XML spec)
- the tree structure is not valid (for example, because of unescaped HTML tags)
Here is some information that I would consider useful though not crucial:
- Performance comparisons
- A list of available implementations
I am currently considering any XML API on the JVM.
- It can be a Java standard (DOM, SAX, StAX, JAXP), or an implementation-specific API.
- It can be an API for any language on the JVM (Scala, Groovy, Jython, JRuby...) - just make sure that it adds something compared to the standard Java APIs.
I believe that a good way to structure this thread would be to only have one API per answer.
回答1:
jaxp is not an implementation but a wrapper/facade api where u can plugin multiple parser implementations. so you are left with sax, dom and stax. now below are two good comparisions and you do the math:
http://techstop.abidshafiq.com/2010/02/java-xml-api-comparison/ http://java.sun.com/performance/reference/whitepapers/StAX-1_0.pdf
回答2:
Look here, you'll get a handful! http://www.xml.com/pub/rg/Java_Parsers
But, I had seen some of my friends using this one in their projects. Though JAXP is widely used, this one looks promising.
Apache Xerces parser version 1.2.3 (http://xerces.apache.org/xerces-j/)
来源:https://stackoverflow.com/questions/3237629/comparison-of-xml-parsing-apis-on-the-java-se-platform