I'm having a SharePoint site where I disabled the "show pages" option in the navigation, and created my navigation using the add static heading/link option. My problem now is that I tried to Programatically read these links, but it seems that topnav.Navigation.GlobalNodes[1].Children is returning all nodes even for those that are hidden (the hidden dynamic nodes for pages). I'm not really sure how can I omit these nodes to get only those explicitly set by the user.
My code is
SPNavigationNodeCollection topnav = _site.Navigation.TopNavigationBar;
foreach (SPNavigationNode node in topnav.Navigation.GlobalNodes[1].Children)
{
strBuilder.Append("<li>");
strBuilder.Append(String.Format("<a href='{0}'>{1}</a>", node.Url, node.Title));
if (node.Children.Count > 0)
{
strBuilder.Append(String.Format("<ul>"));
foreach (SPNavigationNode childNode in node.Children)
{
strBuilder.Append(String.Format("<li><a href='{0}'>{1}</a></li>", childNode.Url, childNode.Title));
}
strBuilder.Append(String.Format("</ul>"));
}
strBuilder.Append("</li>");
}
strBuilder.Append("</ul>");