Solved

Reading and loop in web.sitemap in C#

Posted on 2010-09-17
2
1,457 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now