Click here to Skip to main content
15,909,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys,

i have an xml file like this:
HTML
<parent1>
<child1>
<text> tExt1 </text>
<text> text2 </text>
<text> text3 </text>
</child1>
</parent1>


i want when i click on a button then child node is delete where Element = text3.

please help me in this.
Posted
Updated 14-Sep-11 18:03pm
v2
Comments
Prerak Patel 15-Sep-11 0:04am    
Added code block.

try something like
Code
C#
var remove_node = xmlDoc.selectSingleNode("/parent1/child1[text='text3']")
xmlDoc.documentElement.removeChild(remove_node)
 
Share this answer
 
Comments
Member 8214635 15-Sep-11 0:11am    
if i want to delete a text which is in an additional text box.
AditSheth 15-Sep-11 1:11am    
what mean by additional text box..? I am not getting what you want to delete..
Thanks
C#
XDocument XMLDoc = XDocument.Load("test.xml");
string id = "123";

var myNode = (from xml2 in XMLDoc.Descendants("Node")
               where xml2.Element("ID").Value == id
               select xml2).FirstOrDefault();

myNode.Remove();
XMLDoc.Save("test.xml");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900