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

removing node DOM

 
Brandon Broschinsky
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my program i am using DOM model. I have it set up to remove a node and all it's children which it does. The problem is it leaves a tag when it's done. For example I have a node <entry>..children..<entry> when i remove the entry and it's children, when i write the tree to a file it leaves a node with no children as <entry/> I am not sure why. He is my code to remove the node.

Node current= currentEntry;
System.out.println(current.getNodeName().toString());
while(current.hasChildNodes()){
current.removeChild(current.getFirstChild());
}

currentEntry is the current node that i am on in my tree.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brandon Broschinsky:
In my program i am using DOM model. I have it set up to remove a node and all it's children which it does. The problem is it leaves a tag when it's done. For example I have a node <entry>..children..<entry> when i remove the entry and it's children, when i write the tree to a file it leaves a node with no children as <entry/> I am not sure why. He is my code to remove the node.

Node current= currentEntry;
System.out.println(current.getNodeName().toString());
while(current.hasChildNodes()){
current.removeChild(current.getFirstChild());
}

currentEntry is the current node that i am on in my tree.


Isin't this because you are removing only the Child Nodes. If you want to remove this Node also (current), then



Haven't tested this but based on your description and the API, this is the closest thing I can suggest.
Thanks.

- m
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic