Reading editing deleting in DOM

B

Buddha

Dear all,

I did some search and found this to be the most responsive group.
Could somebody please show me using code how I could delete a child
node (off a specific parent node) from XML using DOM ?

Thanks in advance for your time.

Regards,
 
G

Greg R. Broderick

Could somebody please show me using code how I could delete a child
node (off a specific parent node) from XML using DOM ?

You would use the method org.omg.dom.Node.removeChild(Node oldChild) on
the parent node of the node which you wish to delete, passing a reference
to the node that you wish to delete as the 'oldChild' parameter, so:

Node parent = node.getParentNode();

if (parent != null)
{
parent.removeChild(node);
}

Cheers!
GRB

--
---------------------------------------------------------------------
Greg R. Broderick (e-mail address removed)

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
 
B

Buddha

thanks Thomas and Greg for your replies.
I will post back with whatever code I figured out.

thanks again.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top