.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Linq;

public class Program
{
	public static void Main()
	{
		var xml = @"<?xml version=""1.0""?>
		<student_update date=""2022-04-19"" program=""CA"" checksum=""20021682"">
			<transaction>
				<program>CA</program>
				<student_no>10010823</student_no>
				<course_no>*</course_no>
				<registration_no>216</registration_no>
				<type>2</type>
				<grade>90.4</grade>
				<notes>Update Grade Test</notes>
			</transaction>
			<transaction>
				<program>CA</program>
				<student_no>10010859</student_no>
				<course_no>M-50032</course_no>
				<registration_no>*</registration_no>
				<type>1</type>
				<grade>*</grade>
				<notes>Register Course Test</notes>
			</transaction>
		</student_update>";
		
		XDocument xDocument = XDocument.Load(new StringReader(xml));
		XElement root = xDocument.Element("student_update");
		IEnumerable<XElement> studentnoElement = xDocument.Descendants().Where(x => x.Name == "student_no");

		int checksum = studentnoElement.Sum(x => Int32.Parse(x.Value));
		Console.WriteLine(checksum);
		Console.WriteLine(root.Attribute("checksum").Value.GetType());
		int rootCheckSum = Convert.ToInt32(root.Attribute("checksum").Value);
		Console.WriteLine(rootCheckSum == checksum);
		if (!rootCheckSum.Equals(checksum))
		{
		  //throw new Exception(String.Format("Incorrect checksum total " + "for file {0}\n", inputFileName));
			throw new Exception(String.Format("Incorrect checksum total " + "for file \n"));
		}
	}
}
;