This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unmarshal a modified xml file" Watch "Unmarshal a modified xml file" New topic
Author

Unmarshal a modified xml file

Asmaa Samouna
Greenhorn

Joined: May 14, 2013
Posts: 2
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

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

Joined: Oct 14, 2005
Posts: 18150
    
    8

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: 41
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unmarshal a modified xml file
 
Similar Threads
XML-JAXB ValidationException
Server Program - Responding To Post Requests From HTML pg.
Struts 2 validation not working
Apache POI HWPF getFooter() to extract incremental page numbers from document footers
Read a .xls,.xlsx file format using XSSF