I wrote the following code to count the node of an XML file:
private Dictionary<string, int> ExtractNodeInfo(string fileContent)
{
XmlDocument xmlDocument;
xmlDocument = new XmlDocument();
xmlDocument.Load(fileContent);
var ediNodes = xmlDocument.DocumentElement.SelectNodes("/EDI");
Dictionary<string, int> nodeCount = new Dictionary<string, int>();
foreach (XmlNode nodes in ediNodes)
{
FileManager.nodeRecurse(nodes, nodeCount);
}
foreach (var entry in nodeCount)
{
Console.WriteLine(entry.ToString());
}
}
But it gives me the following error: ‘XmlFileManager.FileManager.ExtractNodeInfo(string)’: not all code paths return a value.
You aren’t returning a value.
You need a return statement at the end of your method, in this case: