Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Answers


Check following sample LINQ and C# code

XML:

<?xml version="1.0" encoding="UTF-8"?>
<
Collage>
  <
Students branch="IT">
    <
Student id="1">Shourya</Student>
    <
Year>2014</Year>
    <
teacher>Nagnath</teacher>
  </
Students>
  <
Students branch="IT">
    <
Student id="2">Shrad</Student>
    <
Year>2015</Year>
    <
teacher>Girish</teacher>
  </
Students>
 
  <
Students branch="Mechanical">
    <
Student id="3">aditya</Student>
    <
Year>2015</Year>
    <
teacher>Balaji</teacher>
  </
Students>
  </
Collage>

Code:

   

XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(
"~/nmk/students.xmal");
           
XmlNode specificStudent =

xmlDoc.SelectSingleNode("/Collage/Students/Student[@ID='2']");
           
if (specificStudent != null)
               
if (specificStudent.ParentNode != null)

specificStudent.ParentNode.RemoveChild(specificStudent);
           

xmlDoc.Save("~/nmk/students.xmal");
  

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.