Java and XML.

Java and Tux - Java and Tux fighting in a battle.
@andben (1075)
Italy
September 27, 2007 3:03pm CST
I know XML is a very good way to store data independent from platforms to share with everybody. Do you have experience using XML with Java? Where can I start to learn something about it?
3 responses
• Italy
20 Dec 07
Ciao! I know what you need: Jdom ;) It's a library for using xml and java. I did a small little project using xml to store data, it's really simple, once you have a few examples of code you copy them over and over and you are perfectly fine. I would suggest going to www.html.it , it's an italian site that teaches you about everything about java. But I don't remember if they talk about jdom too. Why do you need xml for storage?
1 person likes this
@andben (1075)
• Italy
21 Dec 07
I know jdom, but I chose JAXB, I think it's better for my task. I need xml only to store configuration infromation and some other things, my xml files can reach 3000 lines, but they work fine.
• Canada
9 Oct 07
Performance depends on the way XML files are parsed. Many programming languages provide 2 flavors of parsers hierarchical parsers and stream parsers. Hierarchical parsers load the whole XML document in memory and then exploit the hierarchy of that document to analyze it and allow the program to go through the different its different nodes. Stream parsers do not load the whole document in memory. Setting a stream parser involves event-drivent programming and the writing of several callback functions. Hierarchical parsers are easy to program, but inefficient especially for large XML files. Stream parsers are more difficult to set, but are more efficient. I use XML to exchange data between the server and client machines. I always make sure that the size of the XML documents are reasonable. I use XML parsers in Ruby, Javascript and more recently with PHP. I use hierarchical parsers with Ruby and Javascript and a stream parser with PHP. As configuration files tend to be small, a hierachical parser is the route to go. I am pretty sure that Java provides a class to implement such parsers.
@andben (1075)
• Italy
11 Oct 07
I agree with you. I have found a lot of parsers for Java. I use to use XML for configuring reasons and a DBMS to maintain a lot of data.
• Indonesia
3 Oct 07
Don't use XML for storing large data. It is painful. You will take very long time to make searching inside XML. If you use XPATH, searching can be faster, but xpath takes huge memory resource. If you want to store data that is language friendly, consider using embedded database like mysqllite, or use XML as webservices (like SOAP)
@andben (1075)
• Italy
3 Oct 07
Thank you for the suggestion, I don't want to use XML as a replacement of a DBMS, but just as a configuration file for an application.