Re: removing nodes from xmldocument

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: e-mid (someone_at_somewhere)
Date: 07/01/04


Date: Thu, 1 Jul 2004 09:53:13 +0300

thnkz all...
"e-mid" <someone@somewhere> wrote in message
news:u4XnM7rXEHA.1656@TK2MSFTNGP09.phx.gbl...
> Here is an xml structure. i want to remove <a> nodes that do not have any
> child. How can i do that in csharp?
> <root>
> <a>
> <b/>
> </a>
> <a/>
> <a/>
> <a>
> <c/>
> </a>
> </root>
>
> i tried following but it does not work:
>
> xmlNodeList l = xr.getElementsByTagName("a");
>
> foreach(XmlNode n in l)
> {
> if(n.HasChildNodes == false) xr.RemoveChild(n)
> }
>
>



Relevant Pages