Hi,
In my wcf application, i want to load xml file
i use this code but showing error.
error is object reference not set instance of an object
public class Service : IService
{
public IEnumerable<person> disp(string city)
{
XDocument xmlDoc = XDocument.Load(HttpContext.Current.Server.MapPath("people.xml"));
IEnumerable<person> persons = from p in xmlDoc.Descendants("person")
where p.Element("City").Value == city
select new person
{
Name = p.Element("Name").Value,
City = p.Element("City").Value,
Age = p.Element("Age").Value,
};
return persons.ToList();
}
}
how to solve this.
Regards
Baiju