• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unmarshal a modified xml file

 
Asmaa Samouna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my java project I need to unmarshal an xml file in order to get a list of objects.

The unmarshalling works very fine but the problem is encontourned when the content of the file is modified. In fact in this project we can add new contents to this file by clicking on "addButon" but when i want to unmarshal another time the same file (after modification) i get only the old list of objects without the last elements (I have just added to this file).

I already verified the physical xml file on the disk and I found all the last content I just added. Also I noticed that The only way to get the last list of objects is to close the appli and to reopen it again, which is unsuitable.

Here is a piece of the code:

//classe1.java

...


//classe2.java

...
 
Asmaa Samouna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, do you have any idea to resolve this problem?
Thank you in advance.
 
Paul Clapham
Sheriff
Posts: 21002
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could explain how that code is related to your question?

I don't see anything which appends to a file, for example, and that action is what causes your problem, or so you say. Hopefully you aren't trying to append data to an existing XML document, that is only going to cause you problems.
 
Toby Eggitt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not at all sure I understand your question, but I'm going to have a wild stab at answering what I think you might be asking. Your code doesn't even contain enough to see what tools you're using to do the marshal/unmarshal, but I'll make a wild guess and assume you're using JAXB, because I saw the word "unmarshal" in your code. That's a really weak assumption though, so I hope I'm not completely wasting my time and yours

I believe you're saying that you create an object, write it to a file, add more XML fields to the file, and then bring it back. Well, if you're using JAXB that won't work, simply because JAXB is expeting to create a particular type of Java object built against a particular Java Class.

But, since there's at least some mention of Map in your code too, I'm probably barking up the wrong tree.

HTH,
Toby.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic