This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Removing a Child Node using JAXP and DOM Parser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Removing a Child Node using JAXP and DOM Parser" Watch "Removing a Child Node using JAXP and DOM Parser" New topic
Author

Removing a Child Node using JAXP and DOM Parser

Sultan Khadar
Ranch Hand

Joined: Sep 12, 2006
Posts: 75
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Removing a Child Node using JAXP and DOM Parser
 
Similar Threads
Bug in JRE XML parser
Append Child node in DOM
How to parse this type of XML file?
Parsing XML file
some notes on xml