• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing a Child Node using JAXP and DOM Parser

 
Sultan Khadar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • 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
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic