I need some java code to store my resultset in a xm file (ie the details about some books ).
and next the buyer or the user will select the books deponds on the price ,so i have to store all the books in a xml
and search acording to the price. can any one help me.
Writing out data to an XML file can be accomplished in a *lot* of different ways, from just marshaling the data "by hand" (in other words, just writing XML tags and the data from the result set to a file manually) to using any number of XML libs/transformation solutions.
As far as searching goes I'm not quite sure what your actual requirements are here--how the data is stored shouldn't really matter to the searching, unless they're searching XML by just looking at the file. If you want the data ordered in the XML file there are also a number of ways that could be done.
What are your *actual* requirements?
Joined: Jul 11, 2009
I want to store the data retrieved from the database in a XML format and from that i will select some records which satisfy the criteria .I don't want to go again and hit the db server. i can take the details from the XML file itself . without hitting the db server.
Here's an example of something I sometimes do. In this example, the xml is "manually generated" but it's pretty simple code I think. This method gets an object which contains various fields (which end up being elements in the xml). The object was created by other code which just looped through the results assigning the results of each field to a field in the object. Once the CMRAll object is created, then "xmlIt" is called with that object as a parameter. This code just loops through all the fields and for each field an element is created and then the value of that field is added. The nice thing about this code is that it's relatively reusable because none of the fields are hardcoded, this method just figures out what fields exist and what their values are.
FWIW (w/ normal edited code caveats):Note that this will only print public fields--using public properties runs counter to most Java programming philosophies, but may work fine for your situation.
As simple as this is, I'd still probably just use an existing library for this functionality, probably one that allowed marking (and possibly transforming) input bean properties via annotations etc.
Joined: Jul 11, 2009
Thanks for your valueable efforts , spending time for me .But i am now not in the office. my company is closed due to some finacial suitation .if i get another chance i will surely disturb you all guys until bye .
Thanks @ Regards
subject: how to convert a result set into a xml file