• 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

Removing a Child Node using JAXP and DOM Parser

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

is there any way to remove a specific node from XML file using JAXP and DOM parser
Please find the XML file below.



from the above XML file if i want to remove only the node


Which is the child of node <bookshelf id="2"> and save the xml file with this change, how can i do it using JAXP and DOM Parser?
Please help
Any small help would be appreciated.

Thanks.
Sultan
 
Marshal
Posts: 28193
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
Well, you get a reference to the node you want to remove, then you get a reference to its parent, then you call parent.removeNode(child). Don't forget, that just changes your DOM. It doesn't change the original document from which you created the DOM. So you have to serialize the DOM back to a file.
reply
    Bookmark Topic Watch Topic
  • New Topic