Hi Everone,
I have an xml file as follows. Can anybody tell how to delete
Allen record from the following file.?
<Employee>
- <Emp>
<ENo>101</ENo>
<EName>Narendra</EName>
<Job>ASE</Job>
<Sal>5000</Sal>
</Emp>
- <Emp>
<ENo>jdkljf</ENo>
<EName>DKLFJ</EName>
<Job>DJKLAJ</Job>
<Sal>KJDKLFJ</Sal>
</Emp>
- <Emp>
<ENo>DJFJA</ENo>
<EName>JKLJKLJ</EName>
<Job>JKLJKL</Job>
<Sal>JKLJ</Sal>
</Emp>
- <Emp>
<ENo>103</ENo>
<EName>Allen</EName>
<Job>Accounts</Job>
<Sal>2500</Sal>
</Emp>
</Employee>
I Used the following code and found Error: Object reference not set to an instance of an object.
And observed that ParentNode is null when i use the following code..
XmlDocument doc=new XmlDocument();
doc.Load(Server.MapPath(@"~/App_Data/XmlFile.xml""));
XmlNode node = doc.SelectSingleNode("//EName[@" + txtEName.Text + "]");
doc.ParentNode.RemoveChild(node);
U can mail to ttarakarajesh@gmail.com, if u have solution.
ThanQ
Tarak