Solved

Reading and loop in web.sitemap in C#

Posted on 2010-09-17
2
1,531 Views
Last Modified: 2012-06-21
Hi,

I am working in ASP.net using c#

I have generated menu and navgation  using web.sitemap

How do I loop to web.sitemap programtically and get the values of each attrbutes and tag values

Please help

Many Thanks
0
Comment
Question by:tia_kamakshi
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 33707996
A simple recursive loop should do the trick:

 
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteMapNode rootNode = SiteMap.RootNode;
            ProcessNode(rootNode);

        }

        private void ProcessNode(SiteMapNode parentNode)
        {
            Response.Write(parentNode.Url + " (" + parentNode.Title + ")<br />");

            if (parentNode.HasChildNodes)
                foreach (SiteMapNode node in parentNode.ChildNodes)
                    ProcessNode(node);
        }

Open in new window

0
 

Author Closing Comment

by:tia_kamakshi
ID: 33735285
Many Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question