protected override void ProcessOutput(CodeDocument doc) { // Compile expression string result; int animalCount = 0; try { result = "ok\r\n"; // doc.ChildNodes.OfType<CodeElement>().FirstOrDefault(); animalCount = doc.Nodes("valueline").Count(); result += "Number of animals: " + animalCount + "\r\n"; } catch (Exception e) { Output = "Output cant be read.\r\n" + e.Message + "\r\n"; return; } try { float longlivitySum = doc.Nodes("valueline").Sum(node => int.Parse(node.Nodes("valueC").FirstOrDefault()?.Value ?? "0")); if (animalCount > 0) { result += "Average longevity: " + longlivitySum / animalCount; } } catch (Exception e) { result += "longevity cant be read.\r\n" + e.Message + "\r\n"; } Output = "Csv data: " + result; }