xworkload.SelectNodes("//Interview/Rack").Count
Using your code, if all you need is to display the number of Rack nodes :
XmlDocument xworkload = new XmlDocument();
private void btnTotalRack_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document";
dlg.DefaultExt = ".hpa";
dlg.Filter = "Xml document (.hpa)|*.hpa";
var result = dlg.ShowDialog(); //Opens the dialog box to select the xml file
if (result == true)
{
try
{
xworkload.Load(dlg.FileName); //load the Xml file in XmlDocument
MessageBox.Show("The Total number of Racks are :" + xworkload.SelectNodes("//Interview/Rack").Count);
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
}
This should display the output as 5 in the popup.