private void CheckElements(string sectionPath, XmlDocument antaresDoc, XmlNode node, IISServer server) { var map = new ElementCountMap(); foreach (XmlNode childNode in node.ChildNodes) { map.Add(childNode.Name); } foreach (XmlNode childNode in node.ChildNodes) { var formatStrCollection = string.Empty; var formatStr = string.Empty; bool isCollection = map[childNode.Name] > 1; if (sectionPath.StartsWith("configSchema/")) { formatStr = ElementFormat; if (childNode.Name.Equals("clear")) { formatStrCollection = ElementCollectionClearFormat; } else if (childNode.Name.Equals("remove")) { formatStrCollection = ElementCollectionRemoveFormat; } else { formatStrCollection = ElementCollectionFormat; } } else { if (childNode.Name.Equals("clear")) { formatStrCollection = RootedElementCollectionClearFormat; } else if (childNode.Name.Equals("remove")) { formatStrCollection = RootedElementCollectionRemoveFormat; } else { formatStrCollection = RootedElementCollectionFormat; } formatStr = RootedElementFormat; } var childSectionPath = string.Empty; var childSectionPathSingle = string.Format(formatStr, sectionPath, childNode.Name); var childSectionPathColl = string.Format(formatStrCollection, sectionPath, childNode.Name); var sectionFound = false; if (antaresDoc.SelectNodes(childSectionPathSingle).Count > 0) { sectionFound = true; childSectionPath = childSectionPathSingle; } else if (antaresDoc.SelectNodes(childSectionPathColl).Count > 0) { sectionFound = true; childSectionPath = childSectionPathColl; } if (sectionFound) { CheckAttributes(childSectionPath, antaresDoc, childNode, server); CheckElements(childSectionPath, antaresDoc, childNode, server); } else { var message = string.Format("Missing element {0} for path {1}", childNode.Name, childSectionPath); server.SchemaCheckErrors.Add(message); } } }