Let me first show you the xml structure:
<config>
<engine>
<eid>1</eid>
<somechild>text</somechild>
<somemodechild>
<subchild>subchbild</subchild>
<somemorechild>
</engine>
<eid>1</eid>
<somechild>text</somechild>
<somemodechild>
<subchild>subchbild</subchild>
<somemorechild>
</engine>
<engine>
<eid>1</eid>
<somechild>text</somechild>
<somemodechild>
<subchild>subchbild</subchild>
<somemorechild>
</engine>
</engine>
<eid>1</eid>
<somechild>text</somechild>
<somemodechild>
<subchild>subchbild</subchild>
<somemorechild>
</engine>
<engine>
<eid>1</eid>
<somechild>text</somechild>
<somemodechild>
<subchild>subchbild</subchild>
<somemorechild>
</engine>
</config>
Here <config> is the root element. I have to create a GUI to edit xml element. I have done it, using JSP and have a made a GUI for each <engine> in the same page, go the each user can edit a particular <engine> and then save the <config> elements, and to save the changes to that particular <engine> tag i am using eid to segregate the particular <engine>.
Now, I want to rewrite the particular <engine> being edited in a separate xml file. How can I achieve it using jdom?
Not sure if I correctly understand your requirements:
You have a xml file (file A) above as posted above and another xml file (file B) containing only one engine-node.
If you have a unique ID (eid?) in file A parse it into your DOM and then replace the node where the eid matches the eid in file B.
To find the engine in file A that matches the eid in file B, you could use XPath.
then you would remove aEID from your first DOM
and add bEID
(the code above is not meant to compile)