public SiteMapMenu GetMap() { UserInfo u = _sessionManager.UserInfo; XmlDocument xd = new XmlDocument(); xd.Load(HttpContext.Current.Server.MapPath("~/Web.sitemap")); XmlNode xnl = xd.ChildNodes[1]; SiteMapMenu msn = new SiteMapMenu(); foreach (XmlNode x in xnl.ChildNodes) { if (x.NodeType == XmlNodeType.Comment) { continue; } if (x.Attributes["roles"] == null || x.Attributes["roles"].Value.ToString() == "" || MenuShow(x.Attributes["roles"].Value.ToString().Trim(), u.RoleID)) { SiteMapMenu xmsn = new SiteMapMenu() { Title = x.Attributes["title"].Value.ToString(), Des = x.Attributes["description"].Value.ToString(), Url = x.Attributes["url"].Value.ToString() }; foreach (XmlNode xx in x.ChildNodes) { if (xx.NodeType.ToString() == "Comment") { continue; } if (xx.Attributes["roles"] == null || xx.Attributes["roles"].Value.ToString() == "" || MenuShow(xx.Attributes["roles"].Value.ToString().Trim(), u.RoleID)) { SiteMapMenu xxmsn = new SiteMapMenu() { Title = xx.Attributes["title"].Value.ToString(), Des = xx.Attributes["description"].Value.ToString(), Url = xx.Attributes["url"].Value.ToString() }; xmsn.AddChildren(xxmsn); } } if (xmsn.Children.Length > 0) { msn.AddChildren(xmsn); } } } return(msn); }
public void AddChildren(SiteMapMenu ch) { children.Add(ch); }