locked
Create XML by Generic List RRS feed

  • Question

  • Dear All,

    we are developing project using asp.net using c sharp.i have table like this

    RoleID     RoleName      ParentRoleID       NavigateURL

     

       1             Intact               Null                      Intact.aspx

     

       2            User                     1                         UserDirctory.aspx

     

       3              Project                 1                         ProjectDirctory.aspx

     

       4              Userview             2                        UserView.aspx

     

       5             ProjectView           3                        ProjectView.aspx

     

    From above mentioned table, Intact is parent that means parent menu and User and Project are SubMenu  and UserView is submenu of User and ProjectView is submenu of Project.if you want more clarification refer ParentRoleID in above mentioned table,

    I have method namely Public List<Role> GetMenu() and Role class has properties are RoleID,RoleName,ParentRoleID and NavigateURL.that method get that values from database and return list based on  the table the details will genteate the List will be like this

    List[0]   ----first row from that table

     List[1]   ----Second row from that table

    List[2]  ----Third row from that table

     

    Like this all row from the table will be added to the list.for example List[0], List[1] and List[n] every list have property with values are called RoleID,RoleName,ParentRoleID, and NavigateURL based on values i need to build xml..

    below mentioned xml formate..

    <?xml version="1.0" encoding="utf-8" ?>

    <Home>

                            

    <Menu Text="Intact" NavigateURL="Users.aspx">

     

    <SubMenu Text="User">

              

    <SubMenu Text="UsersView" NavigateURL="UsersView.aspx"></SubMenu>

    <SubMenu Text="WorkLocation" NavigateURL="WorkLocation.aspx"></SubMenu>

    <SubMenu Text="UserPreferences" NavigateURL="UserPreferences.aspx"></SubMenu>

     

    </SubMenu >

                 

    <SubMenu Text="Project" NavigateURL="Projects.aspx">

             

    <SubMenu Text="ProjectView" NavigateURL="ProjectView.aspx" ></SubMenu>

             

    </SubMenu>

                

    <SubMenu Text="Requirement"/>

    <SubMenu Text="Risk"/>

     

    </Menu>

     

    </Home>

    <?xml version="1.0" encoding="utf-8" ?> 
    <Home> 
                             
    <Menu Text="Intact" NavigateURL="Users.aspx"> 
     
    <SubMenu Text="User"> 
               
    <SubMenu Text="UsersView" NavigateURL="UsersView.aspx"></SubMenu> 
    <SubMenu Text="WorkLocation" NavigateURL="WorkLocation.aspx"></SubMenu> 
    <SubMenu Text="UserPreferences" NavigateURL="UserPreferences.aspx"></SubMenu> 
     
    </SubMenu > 
                 
    <SubMenu Text="Project" NavigateURL="Projects.aspx"> 
              
    <SubMenu Text="ProjectView" NavigateURL="ProjectView.aspx" ></SubMenu> 
              
    </SubMenu> 
                 
    <SubMenu Text="Requirement"/> 
    <SubMenu Text="Risk"/> 
     
    </Menu> 
     
    </Home> 
    

    1)Based on that list i need to generate xml file and<o:p></o:p>

    2)Based on that xml i want bind menu with based on above mentioned table ParentRoleID heiarchy and also need allocate navigate URL which is for navigate page from another
    page ..<o:p></o:p>

    How to implement this and i am new to this if you guide me very helpful for me..<o:p></o:p>

    Thanks in Advance..

    Tuesday, September 25, 2012 5:39 AM

Answers