Skip to content
Advertisement

Can a part of XML be marshalled using JAXB (or JAXB + StAX)?

I have an XML structure which is very huge. I want to update the parts of this XML, by unmarshalling one element and then applying business logic.

I am able to unmarshal a child element into a POJO. I want to make changes to this POJO in Java and then update it back to the XML at the same location.

Is this possible in JAXB? Or by using the combination of JAXB + StAX.

Example Structure :

JavaScript

In the above example, I am able to unmarshal a ‘file’ element into a POJO. I want to make changes to this POJO and then update the same in the XML file at its correct location.

How can I accomplish this ?

Please help me. Thanks.

Advertisement

Answer

You could do the following with JAXB and StAX:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement