开发者

API for XML programming [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will 开发者_如何学Clikely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

Is there any good Java API that i can use to create XML documents where i can eliminate all the boilerplate code using SAX and DOM parsers. I am also looking for an API that can create CSV file from xml document. Suggestions can make my work faster..


It looks like you're asking two questions here:

  1. Check out the excellent dom4j library for simplified XML document creation.

  2. See the Apache Commons CSV project and SuperCSV.


dom4j or JDOM for simple XML. I've never done anything with CSV in Java, but CSV isn't very complex, and a Google search turned up some promising results.


Check out the StAX API, which is located in package `javax.xml.stream´. It's been included in Java SE since version 1.6 and as far as I know is the only non-third-party Java API that can be used to write documents in an orderly fashion. I'm not certain why you mention boilerplate code of SAX and DOM parsers, since those are for reading XML, not writing.

All the recommendations by others here are good too, but before you start using an object-model approach like JDOM, keep memory overhead in mind. You could run into trouble for large documents.

Finally, should the intended documents lend themselves to this, you could have a more Java-centric approach through JAXB. This won't be ideal for any sort of XML, mind you. It depends on what you wish to do with it. Again, memory usage will be higher than streaming small bits at a time, although JAXB uses StAX when un/marshalling.


XStream is not SAX based, its stream based but you do almost everything using annotations. Very good and easy to use.

http://x-stream.github.io/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜