Solutions for Storing Data XML, Databases and...?
I have a piece of software for reviewing cigars, the user enters the stats (name, price, brand, country, length etc) and a review (maybe a paragraph or two). Theres a menu for searching for previously reviewed cigars which will pull开发者_如何学运维 the stats and review for that cigar. At the moment its easy to search for the cigars because the data is all stored in a mysql db on a local server (for example i have a button 'country' which will fill the menu with the countries of the cigars stored in the db(cuba, nicuragua etc...then clicking on the country will fill the menu with the names of the cigars from that country - clicking on the names obviously brings up the stats and review))
I want to convert it so that the data is stored in xml files that the software will create. Is this easy to do? Bearing in mind that the xml files will need to be updated everytime a new review is written? I started trying out XStream but im thinking perhaps JAXB might be better? My question is, is there another way to store data that would be more appropriate? Am i thinking along the right lines using xml files and JAXB?
Thanks for any input
Sorry to side-step a bit from your question. As the above comments already mentioned, the best solution is what you have right now, store it in a database. There will be many problems arising from using only XML files to store and maintain all that information (and you application will be alot slower and limited on the queries you can do).
If I understood correctly, your considering XML because you want the application to be completly self contained. If this is so, I suggest another approach. Try another database engine, like SQLite3 or H2. You can simply add a jar to your application and if you read a bit of the documentation, it's really easy to maintain the database in a simple file, no installations required. SQLite3 is currently used in most web frameworks like Django, RoR, etc as an out of the box database, so you can start implementing away.
There's also the plus side that your current logic will probably work "as is", since both these databases support standard SQL.
Think this might solve your problem?
Best Regards, Pedro
精彩评论