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 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>

Linq to XML Query:

XDocument XD = XDocument.Load("~/nmk/students.xml");
            XD.Root.Descendants(
"Student")
                   .Where(el => (
string)el.Attribute("id") == "1")
                  .Remove();

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.