Java and XML.
By andben
@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
@RowenaTheWitch (947)
• 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?
@spiderman05 (851)
• 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.
@indra_e00 (44)
• 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)