File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting child nodes from an xml

 
reggie rui
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following xml:



I want to delete the child depending on the "name" attribute. Is there a way to do this ? i tried to do this with DOM but didnt work. Also, i can get the specific child node using XPath. But then again, how do i delete it from the xml ?

Thanks in Advance
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look in the API documentation for the Node interface of DOM, you surely will find a method which deletes, or perhaps removes, a Node. Just scan down the list of methods until you find it. You would use that method once you have a reference to the node.

If you are still stuck, post your code and let's discuss it.
 
Sharad Khanna
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to parse the XML using either jdom or java.xpath libraries and delete the node.



reggie rui wrote:I have the following xml:



I want to delete the child depending on the "name" attribute. Is there a way to do this ? i tried to do this with DOM but didnt work. Also, i can get the specific child node using XPath. But then again, how do i delete it from the xml ?

Thanks in Advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried to do this with DOM but didnt work.



Why do people make statements like that and expect help

What is the code you wrote? What happened when you ran it?

You do realize that having modified the DOM in memory you still need to write it to a file, right?

Bill
 
s ithu
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic