Reputation: 2348
i have been used JDOM to perform xml data entry & updation in any XML file, but now i am trying to use JAXB instead of JDOM but getting some difficulties.
as i know marshalling & unmarshalling in jaxb but when it comes to entry a new data into a xml at specified location (node
), i find difficulties. e.g. for new entry Japan where id = Asia
<file>
<parent>
<node id="Asia">
<name>India</name>
<name>China</name>
</node>
<node id="Europe">
<name>UK</name>
</node>
</parent>
</file>
is there anybody who has idea about it.
Upvotes: 2
Views: 4820
Reputation:
If I'm not mistaken JAXB and JDOM and completely different things. JAXB will serialize java objects into an XML format and vice versa. JDOM simply reads in the XML file and stores it in a DOM tree which can then be used to modify the xml itself.
Using JAXB in this way is like trying to at runtime add a new variable to a class. It cannot be done. (at least to my knowledge).
Upvotes: 3