[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1049
  • Last Modified:

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>
0
khan2000
Asked:
khan2000
  • 8
  • 6
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now