XML Document Execution using Restsharp.
var client = new RestClient("Web service url/");
string url = string.Format("MobileApp/api/JobSeeker/Interview/SessionID/{0}/lng/{1}", sessionID,language);
var request = new RestRequest(url, Method.GET);
request.AddParameter("Authorization-Token", "ZJ6/3tldwf1gHj6uMUVSgQ==", ParameterType.HttpHeader);
client.ExecuteAsync(request, response =>
{
InterviewResponse(response.Content);
});
private void InterviewResponse(string xmlString)
{
XDocument x = XDocument.Parse(xmlString);
var collections = x.Root.Elements().ToList();
List<interviews> listofJobs = new List<interviews>();
foreach (var item in collections)
{
Interviews job = new Interviews();
foreach (var el in item.Elements())
{
switch (el.Name.LocalName)
{
case "EmployerName":
job.EmployerName = el.Value;
break;
case "InterviewType":
job.InterviewType = el.Value;
break;
case "JobCode":
job.JobCode = el.Value;
break;
case "JobTitle":
job.JobTitle = el.Value;
break;
case "Location":
job.Location = el.Value;
break;
case "Schedule":
job.Schedule = el.Value;
break;
}
}
listofJobs.Add(job);
}
}
</interviews></interviews>