• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading a XML file with another XML

 
Randy Miller
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

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.
To illustrate:

File A:

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 ;)

Greetings,

Randy
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't work? What makes you think that?
 
g tsuji
Ranch Hand
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Randy Miller
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

You ARE AWESOME
It worked
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic