protected virtual IEnumerable <ISiteMapNodeToParentRelation> LoadSiteMapNodesFromXml(XDocument xml, ISiteMapNodeHelper helper) { var result = new List <ISiteMapNodeToParentRelation>(); xmlNameProvider.FixXmlNamespaces(xml); // Get the root mvcSiteMapNode element, and map this to an MvcSiteMapNode var rootElement = GetRootElement(xml); if (rootElement == null) { // No root element - inform the user this isn't allowed. throw new MvcSiteMapException(string.Format(Resources.Messages.XmlSiteMapNodeProviderRootNodeNotDefined, helper.SiteMapCacheKey)); } // Add the root node var rootNode = GetRootNode(xml, rootElement, helper); if (includeRootNode) { result.Add(rootNode); } // Process our XML, passing in the main root sitemap node and xml element. result.AddRange(ProcessXmlNodes(rootNode.Node, rootElement, NodesToProcess.All, helper)); // Done! return(result); }
public IList <string> GetAttributeValues(IXmlSource xmlSource, string attributeName) { var xml = xmlSource.GetXml(); xmlNameProvider.FixXmlNamespaces(xml); var result = xml.Element(xmlNameProvider.RootName) .Descendants() .Select(e => (string)e.Attribute(attributeName)) .Where(x => x != null) .Distinct() .ToList(); return(result); }
protected virtual ISiteMapNode LoadSiteMapFromXml(ISiteMap siteMap, XDocument xml) { xmlNameProvider.FixXmlNamespaces(xml); // Get the root mvcSiteMapNode element, and map this to an MvcSiteMapNode var rootElement = GetRootElement(xml); var root = GetRootNode(siteMap, xml, rootElement); // Fixes #192 root node not added to sitemap if (siteMap.FindSiteMapNodeFromKey(root.Key) == null) { // Add the root node to the sitemap siteMap.AddNode(root); } // Process our XML, passing in the main root sitemap node and XML element. ProcessXmlNodes(siteMap, root, rootElement); // Done! return(root); }