XmlDocument GetConfigDocument (string virtualPath)
{
if (String.IsNullOrEmpty (virtualPath))
throw new ArgumentException ("The siteMapFile attribute must be specified on the XmlSiteMapProvider");
string file = HostingEnvironment.MapPath (virtualPath);
if (file == null)
throw new HttpException ("Virtual path '" + virtualPath + "' cannot be mapped to physical path.");
if (String.Compare (Path.GetExtension (file), ".sitemap", RuntimeHelpers.StringComparison) != 0)
throw new InvalidOperationException (String.Format ("The file {0} has an invalid extension, only .sitemap files are allowed in XmlSiteMapProvider.",
String.IsNullOrEmpty (virtualPath) ? Path.GetFileName (file) : virtualPath));
if (!File.Exists (file))
throw new InvalidOperationException (String.Format ("The file '{0}' required by XmlSiteMapProvider does not exist.",
String.IsNullOrEmpty (virtualPath) ? Path.GetFileName (file) : virtualPath));
ResourceKey = Path.GetFileName (file);
CreateWatcher (file);
XmlDocument d = new XmlDocument ();
d.Load (file);
return d;
}