asp.net 循环读取XML文档

XML文档格式如下

[xhtml]  view plain copy
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <menu>  
  3.   <submenu id="1" text="校区基本信息">  
  4.     <item text="校区管理" href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" mce_href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" roles="超级管理员,系统管理员,院校长"></item>  
  5.     <item text="班级管理" href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" mce_href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" roles="超级管理员,系统管理员,班主任,院校长,教学主管,教学主任,校区考试专员" ></item>  
  6.     <item text="学生信息管理" href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" mce_href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>  
  7.     <item text="用户信息管理" href="SchoolBaseSet/UserManagement/UserInformation.aspx" mce_href="SchoolBaseSet/UserManagement/UserInformation.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任"></item>  
  8.     <item text="教师审批管理" href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" mce_href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" roles="教学主管,教学主任,校区考试专员"></item>  
  9.     <item text="切换教师角色" href="SchoolBaseSet/TeacherPass/RolesChange.aspx" mce_href="SchoolBaseSet/TeacherPass/RolesChange.aspx" roles="校区考试专员"></item>  
  10.   </submenu>  
  11.   
  12.   <submenu id="2" text="学生成绩管理">  
  13. <item text="成绩综合管理" href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>  
  14.   <item text="学生成绩管理" href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>  
  15.   </submenu>  
  16.   
  17.   <submenu id="3" text="数据字典设置">  
  18.     <item text="专业管理" href="DataDictionary/Specialty/Specialties.aspx" mce_href="DataDictionary/Specialty/Specialties.aspx" roles="超级管理员,系统管理员" ></item>  
  19.     <item text="课程管理" href="DataDictionary/Course/Courses.aspx" mce_href="DataDictionary/Course/Courses.aspx" roles="超级管理员,系统管理员" ></item>  
  20.     <item text="专业课程管理" href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" mce_href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" roles="超级管理员,系统管理员" ></item>  
  21.     <item text="角色管理" href="DataDictionary/Rolse/Roles.aspx" mce_href="DataDictionary/Rolse/Roles.aspx" roles="超级管理员"></item>  
  22.     <item text="管理员管理" href="DataDictionary/AdminUser/AdministratorUser.aspx" mce_href="DataDictionary/AdminUser/AdministratorUser.aspx" roles="超级管理员" ></item>  
  23.     <item text="Logo图标管理" href="DataDictionary/Logo/EditLogo.aspx" mce_href="DataDictionary/Logo/EditLogo.aspx" roles="超级管理员,系统管理员,教学主管,教学主任" ></item>  
  24.     <item text="学号长度设置" href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" mce_href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" roles="超级管理员,系统管理员" ></item>  
  25.     <item text="恢复设置管理" href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" mce_href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" roles="超级管理员" ></item>  
  26.   </submenu>  
  27.   
  28.   <submenu id="4" text="考试操作管理">  
  29.     <item text="考试类型管理" href="ExamManagement/ExamType/ExamTypeInformation.aspx" mce_href="ExamManagement/ExamType/ExamTypeInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  30.     <item text="试卷模板管理" href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" mce_href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  31.     <item text="试题类型管理" href="ExamManagement/ExaminationType/ExaminationInformation.aspx" mce_href="ExamManagement/ExaminationType/ExaminationInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  32.     <item text="试题题目管理" href="ExamManagement/ExamQuestion/QuestionInformation.aspx" mce_href="ExamManagement/ExamQuestion/QuestionInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  33.     <item text="考试申请管理" href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" mce_href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  34.     <item text="试卷下载管理" href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" mce_href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" roles="超级管理员,系统管理员" ></item>  
  35.     <item text="试卷删除管理" href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" mce_href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" roles="超级管理员,系统管理员" ></item>  
  36.   </submenu>  
  37.   <submenu id="5" text="报表信息管理">  
  38.     <item text="缓考补考报表" href="ReportInformation/StudentExamState/StudentExamState.aspx" mce_href="ReportInformation/StudentExamState/StudentExamState.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>  
  39.     <item text="校区考试报表" href="ReportInformation/ExamGrade/ExamGradeReport.aspx" mce_href="ReportInformation/ExamGrade/ExamGradeReport.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任,校区考试专员" ></item>  
  40.     <item text="班级课程报表" href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" mce_href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>  
  41.   </submenu>  
  42.   
  43.   <submenu id="6" text="日志操作管理">  
  44.     <item text="登陆日志管理" href="LoginManagement/LogLogins.aspx" mce_href="LoginManagement/LogLogins.aspx" roles="超级管理员" ></item>  
  45.     <item text="操作日志管理" href="LoginManagement/LogOpeations.aspx" mce_href="LoginManagement/LogOpeations.aspx" roles="超级管理员" ></item>  
  46.     <item text="日志导出" href="LoginManagement/ErportLog.aspx" mce_href="LoginManagement/ErportLog.aspx" roles="超级管理员" >  
  47.     </item>  
  48.   </submenu>  
  49.   
  50.   <submenu id="7" text="个人信息管理">  
  51.     <item text="个人资料修改" href="PersonalManagement/PersonalManagement.aspx" mce_href="PersonalManagement/PersonalManagement.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>  
  52.   </submenu>  
  53. </menu>  
  

defatult.aspx.cs文件代码

[c-sharp]  view plain copy
  1. XmlDocument x = new XmlDocument();//实例化一个XML文档  
  2. protected void Page_Load(object sender, EventArgs e)  
  3. {  
  4.     XMLopertator();  
  5. }  
  6.   
  7. /// <summary>  
  8. /// 循环读取XML里的内容  
  9. /// </summary>  
  10. public void XMLopertator()   
  11. {  
  12.     XMLLoad();  
  13.   
  14.     XmlNodeList xnl=x.ChildNodes;   
  15.     foreach (XmlNode xn in xnl)  
  16.     {  
  17.         XmlNodeList xnl1 = xn.ChildNodes;  
  18.         foreach (XmlNode xn1 in xnl1)  
  19.         {  
  20.             XmlNodeList xnl2 = xn1.ChildNodes;  
  21.             foreach (XmlNode xn2 in xnl2)  
  22.             {  
  23.                 Response.Write(xn2.Attributes["text"].Value+"<br/>");  
  24.             }  
  25.         }  
  26.     }  
  27. }  
  28.   
  29. /// <summary>  
  30. /// 加载XML文档  
  31. /// </summary>  
  32. public void XMLLoad()  
  33. {  
  34.     x.Load(Server.MapPath("~/Left.xml"));  
  35. }  

转载自:点击打开链接

 

做起来很简单 的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值