• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overloading a XML file with another XML

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Won't work? What makes you think that?
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic