File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Unmarshal a modified xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unmarshal a modified xml file" Watch "Unmarshal a modified xml file" New topic

Unmarshal a modified xml file

Asmaa Samouna

Joined: May 14, 2013
Posts: 2

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:




Asmaa Samouna

Joined: May 14, 2013
Posts: 2
Please, do you have any idea to resolve this problem?
Thank you in advance.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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

Joined: Dec 08, 2004
Posts: 49
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.

I agree. Here's the link:
subject: Unmarshal a modified xml file
jQuery in Action, 3rd edition