This content has been marked as final. Show 6 replies
I would parse the xls via POI and then if you say your xdat is xml, build or modify it using JAXB.
From a high level I dont see a need to store it in a List unless you need to run some business rules over the data.
ok. I am not gonna pull any business rules on the collected data. Just reading each row and putting them in the relevant block inside the xml.
could u refer me some example for creating .xdat in xml, and inserting data in a structured format (which can be any structure I want to have)!
IOW "gimme teh codez".
Excuse me ... but I didn't ask for code. I am asking for tips, cos I want to learn the logic, not how to do copy pasting.... would appreciate if u don't put comments irrelevant to my topic. If u can help, then welcome and write some tips.
yes I tried working with the JAXB .... opened the new file and all.
if a xml structure is as following:
<?xml version = "1.0"?>
.... .... ....
... .... ....
... ... ...
And I have the infos from a excel file ... how should I insert them in this format? I think what I am trying to ask is that... is there any special functions to fill the xml structure? or should I just insert the data in the .xml file depending on which data (Title, ISBN or Publisher) I am reading from the excel file row and column.
If you are using JAXB you unmarshall to read the xml. Then you marshall to write.
So what you do is:
1) Unmarshall your xml document. This means you now have your xml as Java objects.
2) Read through the Java objects using loops, etc making any changes to the values. I think here you want to add values, so you can set your values
3) Now in memory you have your new xml thats been updated, so you can marshall it (save it)
I'd recommend a JAXB tutorial. But the basic steps are:
1) Create an xml file and insure its valid
2) Use a free online utility (http://www.hitsw.com/xml_utilites/) to convert the xml into an xml schema (xsd)
3) Use xjc from the jaxb jar and run it over the xml schema (the command i use is xjc myxmlfile.xsd -p com.example
4) Step 3 above creates all the java classes for you to use so then you can unmarshall. Process. Then marshall
This is just a high level. I might have missed something, but the jaxb tutorial is really good and that's how I learned the process.