public static Batch CreateBatch(string resultXML) { XDocument doc = XDocument.Parse(resultXML); XElement batchInfoElement = doc.Root; List<XElement> jobInfoChildElements = batchInfoElement.Elements().ToList(); Batch batch = new Batch(); foreach (XElement e in jobInfoChildElements) { switch (e.Name.LocalName){ case "id": batch.Id = e.Value; break; case "jobId": batch.JobId = e.Value; break; case "createdDate": batch.CreatedDate = DateTime.Parse( e.Value ); break; case "systemModstamp": batch.SystemModStamp = DateTime.Parse( e.Value ); break; case "state": batch.State = e.Value; break; case "numberRecordsProcessed": batch.NumberRecordsProcessed = int.Parse( e.Value ); break; case "numberRecordsFailed": batch.NumberRecordsFailed = int.Parse( e.Value ); break; case "totalProcessingTime": batch.TotalProcessingTime = int.Parse( e.Value ); break; case "apiActiveProcessingTime": batch.ApiActiveProcessingTime = int.Parse( e.Value ); break; case "apexProcessingTime": batch.ApexProcessingTime = int.Parse( e.Value ); break; } } return batch; }