• 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

Adding an child node from a nodelist.

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to add new elements to a XML document. The elements are being built while looping through a DB result. Each node will have multiple elements added to it but
just 1 level of children.

I'm using XPath to find all of my nodes then creating an element and using append child to the current node in the NodeList. This is not working. what other options
do I have? I would rather not build it as I go but it may be my only choice.

initial XML


Expected XML at the end


 
Marshal
Posts: 28177
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
So what "isn't working" about that code? It looks okay to me.

(You do have code which writes the DOM out to a file somewhere, don't you?)
 
Jon Bricker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:So what "isn't working" about that code? It looks okay to me.

(You do have code which writes the DOM out to a file somewhere, don't you?)



I'm writing out the result when I run the unit test. That code produces no changes to the document


 
Jon Bricker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not happy with how I solved it so I would still like to see what I was doing wrong with editing the document using XPath. It seems very clunky I keep thinking that I'm missing a line of code so the edits would take.



Those changes given this input:



will produce this
reply
    Bookmark Topic Watch Topic
  • New Topic