Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am in a project to develop database menu link. in that i am using a sitmap.when i run the application the following error occurs.

Exactly one siteMapNode element is required directly inside.

This is my sitemap:
XML
<?xml version="1.0" encoding="utf-8" ?>

<siteMap>
 <siteMapNode url="authendicate.aspx" title="Home">
    <siteMapNode title="Employee Manage"  description="Managing Employee details">
      <siteMapNode
               url="NewEmployeeDetails.aspx"
               title="New Employee"
               description="new employee details" />
      <siteMapNode
               url="EmployeeDetails.aspx"
               title="EmployeeDetails"
               description="employee details" />
    </siteMapNode>
    <siteMapNode
        url="EmployeeDetails.aspx"
        title="Activation"
        description="Activate and deactivate employee" />
  </siteMapNode>
  <siteMapNode title="Leave Manage"  description="Managing Leave details">
      <siteMapNode
               url="ApplyForLeave.aspx"
               title="ApplyForLeave"
               description="Apply For Leave" />
      <siteMapNode
               url="ViewLeaveRequest.aspx"
               title="ViewLeaveRequest"
               description="View Leave Request" />
    </siteMapNode>
 </siteMap>


and this is my codebehind file to call sitemap:

private SiteMapDataSource GetSiteMapDataSource()
   {
       XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();
       System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
       myCollection.Add("siteMapFile", "Web.sitemap");
       xmlSiteMap.Initialize("provider", myCollection);
       xmlSiteMap.BuildSiteMap();
       SiteMapDataSource siteMap = new SiteMapDataSource();
       return siteMap;
   }


can anybody help?.
Thanks.
Posted

You need to wrap all your site map nodes inside one site map node. i.e Your sitemap file should look like this:

<sitemap>
  <sitemap>
    <sitemapnode url="authendicate.aspx" title="Home">
      <sitemapnode title="Employee Manage" description="Managing Employee details">
        <sitemapnode>
                 url="NewEmployeeDetails.aspx"
                 title="New Employee"
                 description="new employee details" />
        <sitemapnode>
                 url="EmployeeDetails.aspx"
                 title="EmployeeDetails"
                 description="employee details" />
      </sitemapnode>
      <sitemapnode>
          url="EmployeeDetails.aspx"
          title="Activation"
          description="Activate and deactivate employee" />
    </sitemapnode>
    <sitemapnode title="Leave Manage" description="Managing Leave details">
      <sitemapnode>
               url="ApplyForLeave.aspx"
               title="ApplyForLeave"
               description="Apply For Leave" />
      <sitemapnode>
               url="ViewLeaveRequest.aspx"
               title="ViewLeaveRequest"
               description="View Leave Request" />
    </sitemapnode>
  </sitemapnode></sitemapnode></sitemapnode></sitemapnode></sitemapnode></sitemap>
</sitemap>


else you can also try this[^] solution.

Hope this helps.
All the best.
 
Share this answer
 
v2
Comments
Simon Bang Terkildsen 23-Aug-11 10:21am    
I beleave you need the inner sitemap to be a sitemapnode
You forgot to close the first <siteMapNode> tag. You need to add </siteMapNode> before </siteMap>
 
Share this answer
 
Comments
Pravin Patil, Mumbai 23-Aug-11 9:47am    
No, the xml seems correct to me. Try to copy it in any XML editor, it is correct.
Simon Bang Terkildsen 23-Aug-11 10:20am    
Ah yeah you're correct, so the mistake is having two children of sitemap.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900