An unhandled exception of type 'System.NullReferenceException' occurred in XMLDemos.exe
<?xml version="1.0" encoding="UTF-8" standalone="true"?> -<Employee> -<Employee> -<Employee Id="101"> <Name>Mary</Name> <Gender>Female</Gender> <Salary>10000</Salary> </Employee> -<Employee Id="102"> <Name>John</Name> <Gender>Male</Gender> <Salary>15000</Salary> </Employee> -<Employee Id="103"> <Name>Heena</Name> <Gender>Female</Gender> <Salary>20000</Salary> </Employee> </Employee> -<Employee Id="105"> <Name>John</Name> <Gender>Male</Gender> <Salary>22000</Salary> </Employee> </Employee>
XDocument xmlDocmt = XDocument.Load(@"C:\Users\Pratiksha\Documents\Visual Studio 2015\Projects\Yuga\XMLDemos\Data.xml"); xmlDocmt.Element("Employee") .Elements("Employee") .Where(x => x.Attribute("Id").Value == "101").FirstOrDefault() .SetElementValue("Salary", 30000);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)