siteNavigation

hi

how do i remove "home" from this xml?, if i remove and its throwing me an error:

error:

Exactly one <siteMapNode> element is required directly inside the <siteMap> element.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Exactly one <siteMapNode> element is required directly inside the <siteMap> element.

Source Error:

.xml
====
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
 
  <siteMapNode url="~/Default.aspx" title="Home">  <<<<<<<<<<<<<<<<< I DO NOT WANT
    <siteMapNode url="~/Books/Default.aspx" title="Books" imageUrl="books.jpg">
      <siteMapNode url="~/Books/Novels.aspx" title="Novels" imageUrl="books.jpg" />
      <siteMapNode url="~/Books/History.aspx" title="History" imageUrl="books.jpg" />
      <siteMapNode url="~/Books/Romance.aspx" title="Romance" imageUrl="Heart.gif" />
    </siteMapNode>
    <siteMapNode url="~/Electronics/Default.aspx" title="Electronics" imageUrl="electronics.jpg" />
    <siteMapNode url="~/DVDs/Default.aspx" title="DVDs" imageUrl="dvd.png" />
    <siteMapNode url="~/Computers/Default.aspx" title="Computers" imageUrl="computer.png" />
  </siteMapNode>
</siteMap>
LVL 2
khan2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

khan2000Author Commented:
I should be able to put all the nodes in root like this:

http://aspnet.4guysfromrolla.com/images/siteMap.BulletedList1.png
0
AGBrownCommented:
Your structure is confusing me - if you don't want "home", what is going to happen to the nodes inside it (default, books, novels, history, romance...)? Are they all going to be deleted? That is what is happening at the moment, and that is where your error is coming from.

This is the structure as I see it:

      <siteMapNode url="~/Default.aspx" title="Home">      << delete this and all the stuff inside it goes!!
            <siteMapNode url="~/Books/Default.aspx" title="Books" imageUrl="books.jpg">
                  <siteMapNode url="~/Books/Novels.aspx" title="Novels" imageUrl="books.jpg" />
                  <siteMapNode url="~/Books/History.aspx" title="History" imageUrl="books.jpg" />
                  <siteMapNode url="~/Books/Romance.aspx" title="Romance" imageUrl="Heart.gif" />
            </siteMapNode>
            <siteMapNode url="~/Electronics/Default.aspx" title="Electronics" imageUrl="electronics.jpg" />
            <siteMapNode url="~/DVDs/Default.aspx" title="DVDs" imageUrl="dvd.png" />
            <siteMapNode url="~/Computers/Default.aspx" title="Computers" imageUrl="computer.png" />
      </siteMapNode>

Andy
0
khan2000Author Commented:
i guess what im saying is, i want all in root rather then all under home:

when i copy and paste ur xml, i get this error:


Top element must be siteMap.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Top element must be siteMap.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

khan2000Author Commented:
in other words, i have to have "home" in order to work ?
0
AGBrownCommented:
Sorry, i was not posting a new Xml file for you, I was clarifying the structure with tab indentation.

I am saying that your structure is siteMap --> siteMapNode:Home --> all other siteMapNodes. So, when you delete Home, all of your nodes inside Home are deleted as well. Then you end up with no nodes inside siteMap, and this is giving you the error.

Could you post your code? Then we might be able to help solve your problem.

Andy
0
khan2000Author Commented:
well.. i do understand exactly what you saying but again what im sayin is that

can i have sitemapNode like this:

Novels
History
Romance
Electronics

?
0
AGBrownCommented:
Yes, you can. If you post your code I can help you get to it by refactoring your existing code.

Basically, I would get the Nodes collection from the Home node, copy it and add it to the base node, or just move it to the base node, and then delete the Home node.

Andy
0
khan2000Author Commented:
here is my xml

   <siteMapNode url="~/Default.aspx" title="Home">
          <siteMapNode url="~/Books/Default.aspx" title="Books" imageUrl="books.jpg">
               <siteMapNode url="~/Books/Novels.aspx" title="Novels" imageUrl="books.jpg" />
               <siteMapNode url="~/Books/History.aspx" title="History" imageUrl="books.jpg" />
               <siteMapNode url="~/Books/Romance.aspx" title="Romance" imageUrl="Heart.gif" />
          </siteMapNode>
          <siteMapNode url="~/Electronics/Default.aspx" title="Electronics" imageUrl="electronics.jpg" />
          <siteMapNode url="~/DVDs/Default.aspx" title="DVDs" imageUrl="dvd.png" />
          <siteMapNode url="~/Computers/Default.aspx" title="Computers" imageUrl="computer.png" />
     </siteMapNode>
0
AGBrownCommented:
OK, I'm sorry I think I've missed an important point :-). Are you doing this by hand? I thought you were doing it programmatically.

In that case try this:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="~/Books/Default.aspx" title="Books" imageUrl="books.jpg">
      <siteMapNode url="~/Books/Novels.aspx" title="Novels" imageUrl="books.jpg" />
      <siteMapNode url="~/Books/History.aspx" title="History" imageUrl="books.jpg" />
      <siteMapNode url="~/Books/Romance.aspx" title="Romance" imageUrl="Heart.gif" />
    </siteMapNode>
    <siteMapNode url="~/Electronics/Default.aspx" title="Electronics" imageUrl="electronics.jpg" />
    <siteMapNode url="~/DVDs/Default.aspx" title="DVDs" imageUrl="dvd.png" />
    <siteMapNode url="~/Computers/Default.aspx" title="Computers" imageUrl="computer.png" />
</siteMap>
0
khan2000Author Commented:
i get this error after i copy and past your code in my website.sitemap


Exactly one <siteMapNode> element is required directly inside the <siteMap> element.
0
AGBrownCommented:
Well, I've just done some reading on siteMaps and it looks like you absolutely must have a root element, maybe this is your problem. I think you are having problems due to the schema. Deleting Home is invalidating your xml compared to the schema.

http://gridviewguy.com/ArticleDetails.aspx?articleID=165

If that doesn't help then I'm afraid I seem to have missed the point here somewhat.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
khan2000Author Commented:
thanks AGBrown

i just wanted to double check whether i have to have a root element or not and looks like my doubt is correct
0
AGBrownCommented:
:-) got there in the end
0
khan2000Author Commented:
actually you can do that, i was playing with treeview and here is the code for that:

 <asp:TreeView ID="TreeView1" runat="server" Height="248px" Width="232px" ShowCheckBoxes="All">
            <Nodes>
                <asp:TreeNode Text="1" Value="1">
                </asp:TreeNode>
                <asp:TreeNode Text="2" Value="2">
                    <asp:TreeNode Text="22" Value="22"></asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="3" Value="3"></asp:TreeNode>
                <asp:TreeNode Text="4" Value="4"></asp:TreeNode>
                <asp:TreeNode Text="5" Value="5">
                    <asp:TreeNode Text="55" Value="55"></asp:TreeNode>
                </asp:TreeNode>
            </Nodes>
            <ParentNodeStyle BackColor="Yellow" BorderColor="Red" BorderStyle="Dotted" BorderWidth="2px"
                ChildNodesPadding="3px" />
            <LevelStyles>
                <asp:TreeNodeStyle Font-Underline="False" />
                <asp:TreeNodeStyle Font-Underline="False" />
                <asp:TreeNodeStyle Font-Underline="False" />
                <asp:TreeNodeStyle Font-Underline="False" />
                <asp:TreeNodeStyle Font-Underline="False" />
            </LevelStyles>
            <SelectedNodeStyle BackColor="#FFC0C0" BorderColor="#FFFF80" BorderStyle="Solid"
                BorderWidth="1px" />
            <RootNodeStyle BackColor="#FFE0C0" BorderColor="Yellow" BorderStyle="Groove" BorderWidth="1px" />
        </asp:TreeView>

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.