How to remove more than one child nodes through C#?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/><br/>I tried to remove all the child nodes of a parent node using foreach loop like below<br/><br/><span style="font-size:x-small <span style="font-size:x-small
 

<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff foreach<span style="font-size:x-small (<span style="font-size:x-small;color:#2b91af <span style="font-size:x-small;color:#2b91af XmlNode<span style="font-size:x-small smallNode <span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff in<span style="font-size:x-small childNode)
 
<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff if<span style="font-size:x-small (smallNode.Name == <span style="font-size:x-small;color:#a31515 <span style="font-size:x-small;color:#a31515 "AcSmFileReference"<span style="font-size:x-small )
 

{
smallNode.ParentNode.RemoveChild(smallNode);
}
}<br/><br/>But it is working only for the first child node. After removing the first child node loop has breaked automatically and came out. So the remaining child nodes are still there. How can I remove all the child nodes of "childNode"? Can any one of you help me please?<br/><br/>Thanks in Advance,<br/>Jayahar

{
<span style="font-size:x-small
 


View the full article
 
Back
Top