Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. sitemappath is not showing sub categories...

sitemappath is not showing sub categories...

Scheduled Pinned Locked Moved ASP.NET
databasexmlhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RajpootRohan
    wrote on last edited by
    #1

    Hello friends, I am developing a shopping cart. I need a sitemappath in this. I implemented the code but the problem is that I have a categories table from which the sitemappath is fetching the data. In these categories some are main categories and some are their sub categories. For Example I am having a category structure like this: Glassware>>Beer Glass>>Universal Beer Glass... When I click on glassware, my sitemap shows like this: Home:Glassware Then after that when I click on Beer Glass, the sitemappath disappears. ie the sitemappath is shown till I have one sub-level. I did like this: Please assist me....

    public void GenerateXMLFile(string sFileName)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
        SqlCommand cmd = new SqlCommand("select \* from CATEGORY ", con);
        //SqlCommand cmd1 = new SqlCommand("select \* from PRODUCTS ",con);
        cmd.Connection.Open();
        //cmd1.Connection.Open();
    
        SqlDataReader reader1 = cmd.ExecuteReader();
    
        //Create XML
    
        Encoding enc = Encoding.UTF8;
        XmlTextWriter objXMLTW = new XmlTextWriter(sFileName, enc);
        try
        {
            objXMLTW.WriteStartDocument();//xml document open
    
            //'Top level (Parent element)
            //root node open
            objXMLTW.WriteStartElement("siteMap");
    
            //first Node of the Menu open
            objXMLTW.WriteStartElement("siteMapNode");
    
            //Title attribute set
            objXMLTW.WriteAttributeString("title", "Home");
            objXMLTW.WriteAttributeString("description", "This is home");//Description attribute set
            objXMLTW.WriteAttributeString("url", "~/index.aspx");//URL attribute set
    
            //Loop and create nodes
    
            while (reader1.Read())
            {
                int MasterID = reader1.GetInt32(0);
                objXMLTW.WriteStartElement("siteMapNode");
                objXMLTW.WriteAttributeString("title", reader1.GetString(1));
                objXMLTW.WriteAttributeString("description", reader1.GetString(5));
                objXMLTW.WriteAttributeString("url", reader1.GetString(11));
    
    
                objXMLTW.WriteEndElement();//Close the siteMapNode
            }
            objXMLTW.WriteEndElement();//Close the first siteMapNode
            objXMLTW.WriteEndDocument();//xml document closed
        }
        finally
        {
    
    N 1 Reply Last reply
    0
    • R RajpootRohan

      Hello friends, I am developing a shopping cart. I need a sitemappath in this. I implemented the code but the problem is that I have a categories table from which the sitemappath is fetching the data. In these categories some are main categories and some are their sub categories. For Example I am having a category structure like this: Glassware>>Beer Glass>>Universal Beer Glass... When I click on glassware, my sitemap shows like this: Home:Glassware Then after that when I click on Beer Glass, the sitemappath disappears. ie the sitemappath is shown till I have one sub-level. I did like this: Please assist me....

      public void GenerateXMLFile(string sFileName)
      {
          SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
          SqlCommand cmd = new SqlCommand("select \* from CATEGORY ", con);
          //SqlCommand cmd1 = new SqlCommand("select \* from PRODUCTS ",con);
          cmd.Connection.Open();
          //cmd1.Connection.Open();
      
          SqlDataReader reader1 = cmd.ExecuteReader();
      
          //Create XML
      
          Encoding enc = Encoding.UTF8;
          XmlTextWriter objXMLTW = new XmlTextWriter(sFileName, enc);
          try
          {
              objXMLTW.WriteStartDocument();//xml document open
      
              //'Top level (Parent element)
              //root node open
              objXMLTW.WriteStartElement("siteMap");
      
              //first Node of the Menu open
              objXMLTW.WriteStartElement("siteMapNode");
      
              //Title attribute set
              objXMLTW.WriteAttributeString("title", "Home");
              objXMLTW.WriteAttributeString("description", "This is home");//Description attribute set
              objXMLTW.WriteAttributeString("url", "~/index.aspx");//URL attribute set
      
              //Loop and create nodes
      
              while (reader1.Read())
              {
                  int MasterID = reader1.GetInt32(0);
                  objXMLTW.WriteStartElement("siteMapNode");
                  objXMLTW.WriteAttributeString("title", reader1.GetString(1));
                  objXMLTW.WriteAttributeString("description", reader1.GetString(5));
                  objXMLTW.WriteAttributeString("url", reader1.GetString(11));
      
      
                  objXMLTW.WriteEndElement();//Close the siteMapNode
              }
              objXMLTW.WriteEndElement();//Close the first siteMapNode
              objXMLTW.WriteEndDocument();//xml document closed
          }
          finally
          {
      
      N Offline
      N Offline
      Nishant Singh
      wrote on last edited by
      #2

      Sneha ji, Bottom-Top approach is needed in such scenerio

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups