I know, I already posted this problem, some time ago, but I mistakenly though, I found the solution. But, I didn´t
So basically, to shortly recap what I want to do: I have 2 XML file. Both files have a similar named section. What I want to do is, to replace section A from file A with section A from file B.
The similar named section, both have in common is <note>, but the contained attributes differ from file to file.
File B is just the section, I want to place inside File A,nothing more, while File A is a HUGE file,where you have to locate the correct section first before overloading it.
The overloading process would be perfect if I would save the result in an entirely new XML, not actually overwriting the existing file.
I tried this for weeks now and I just can´t figure this one out...All I got so far was, to append the wanted section to the right file, but that´s still not it...
And the replaceChild(), adoptChild() won´t work too...
Here´s my code so far,hopefully somebody finds the mistake
No matter what I try,it just won´t work...And I already tried a lot of System.out.print-statements to figure this one out,trust me ;)
Notes: I don't see what does it mean by "variableParameters" and I suppose it means "note" in the description. Due to that uncertainty, I use dup.getNodeName() to avoid that uncertainty supposing the replacement is on the same name basis. Also, you've to insert a layer of getDocumentElement() to avoid "note" being the root node of the "biggerXML" file A. If that happens, no replacement would take place but the construction avoids runtime error neither. Those details you can simplify a bit as long as you clean up the messy bit of the code.
Joined: Feb 13, 2012
You ARE AWESOME
Big Thank You to g tsuji
That´s EXACTLY what caused the problem!
For everybody who is looking for the complete solution, here´s the code: