XmlNode FindStartingNode (string virtualPath, out bool enableLocalization)
{
XmlDocument d = GetConfigDocument (virtualPath);
XmlElement docElement = d.DocumentElement;
if (String.Compare ("siteMap", docElement.Name, StringComparison.Ordinal) != 0)
throw new ConfigurationErrorsException ("Top element must be 'siteMap'");
XmlNode enloc = docElement.Attributes ["enableLocalization"];
if (enloc != null && !String.IsNullOrEmpty (enloc.Value))
enableLocalization = (bool) Convert.ChangeType (enloc.Value, typeof (bool));
else
enableLocalization = false;
XmlNodeList childNodes = docElement.ChildNodes;
XmlNode node = null;
foreach (XmlNode child in childNodes) {
if (String.Compare ("siteMapNode", child.Name, StringComparison.Ordinal) != 0)
// Only <siteMapNode> is allowed at the top
throw new ConfigurationErrorsException ("Only <siteMapNode> elements are allowed at the document top level.");
if (node != null)
// Only one <siteMapNode> is allowed at the top
throw new ConfigurationErrorsException ("Only one <siteMapNode> element is allowed at the document top level.");
node = child;
}
if (node == null)
throw new ConfigurationErrorsException ("Missing <siteMapNode> element at the document top level.");
return node;
}