| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Xml;
- using System.Xml.Linq;
- namespace CD67.ModeleMVC.MVC.Internal
- {
- public static class Navigation
- {
- public static string SMap(SiteMapNode node)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- List<SiteMapNode> nodes = new List<SiteMapNode>();
-
- nodes.Add(node);
- if (SiteMap.CurrentNode.ParentNode != null)
- {
- SMap(SiteMap.CurrentNode.ParentNode);
- }
- nodes.Reverse();
- sb.Append("<ul>");
- foreach (SiteMapNode nodeelem in nodes)
- {
- sb.Append(string.Concat("<li><a href=\"", nodeelem.Url, "\">", nodeelem.Title, "</a></li>"));
- }
- sb.Append("</ul>");
-
- return sb.ToString();
- }
- public static string Xmap(string title)
- {
- string toto = "";
- XDocument xmap = XDocument.Load("~/web.sitemap");
- var current = xmap.Ancestors("SiteMapNode")
- .Where(x => (string)x.Attribute("title") == title);
- current.Reverse();
- foreach(var currence in current)
- {
- toto += currence.Attribute("title").Value;
- }
- return toto;
- }
- public static string XmlMap(string title)
- {
- string toto = "";
- XmlDocument xml = new XmlDocument();
- xml.Load(HttpContext.Current.Server.MapPath("/web.sitemap"));
- XmlNodeList nodes = xml.DocumentElement.SelectNodes("//*[@title='" + title + "']/ancestor-or-self::SiteMapNode");
- foreach(XmlNode node in nodes)
- {
- toto += node.Attributes["title"].Value;
- }
- return toto;
- }
- }
- }
|