This content has been marked as final. Show 6 replies
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.