asp.net 循环读取XML文档
2015-04-10 21:59
357 查看
XML文档格式如下
[xhtml] view
plaincopy
<?xml version="1.0" encoding="utf-8" ?>
<menu>
<submenu id="1" text="校区基本信息">
<item text="校区管理" href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" mce_href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" roles="超级管理员,系统管理员,院校长"></item>
<item text="班级管理" href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" mce_href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" roles="超级管理员,系统管理员,班主任,院校长,教学主管,教学主任,校区考试专员" ></item>
<item text="学生信息管理" href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" mce_href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
<item text="用户信息管理" href="SchoolBaseSet/UserManagement/UserInformation.aspx" mce_href="SchoolBaseSet/UserManagement/UserInformation.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任"></item>
<item text="教师审批管理" href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" mce_href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" roles="教学主管,教学主任,校区考试专员"></item>
<item text="切换教师角色" href="SchoolBaseSet/TeacherPass/RolesChange.aspx" mce_href="SchoolBaseSet/TeacherPass/RolesChange.aspx" roles="校区考试专员"></item>
</submenu>
<submenu id="2" text="学生成绩管理">
<item text="成绩综合管理" href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
<item text="学生成绩管理" href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
</submenu>
<submenu id="3" text="数据字典设置">
<item text="专业管理" href="DataDictionary/Specialty/Specialties.aspx" mce_href="DataDictionary/Specialty/Specialties.aspx" roles="超级管理员,系统管理员" ></item>
<item text="课程管理" href="DataDictionary/Course/Courses.aspx" mce_href="DataDictionary/Course/Courses.aspx" roles="超级管理员,系统管理员" ></item>
<item text="专业课程管理" href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" mce_href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" roles="超级管理员,系统管理员" ></item>
<item text="角色管理" href="DataDictionary/Rolse/Roles.aspx" mce_href="DataDictionary/Rolse/Roles.aspx" roles="超级管理员"></item>
<item text="管理员管理" href="DataDictionary/AdminUser/AdministratorUser.aspx" mce_href="DataDictionary/AdminUser/AdministratorUser.aspx" roles="超级管理员" ></item>
<item text="Logo图标管理" href="DataDictionary/Logo/EditLogo.aspx" mce_href="DataDictionary/Logo/EditLogo.aspx" roles="超级管理员,系统管理员,教学主管,教学主任" ></item>
<item text="学号长度设置" href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" mce_href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" roles="超级管理员,系统管理员" ></item>
<item text="恢复设置管理" href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" mce_href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" roles="超级管理员" ></item>
</submenu>
<submenu id="4" text="考试操作管理">
<item text="考试类型管理" href="ExamManagement/ExamType/ExamTypeInformation.aspx" mce_href="ExamManagement/ExamType/ExamTypeInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷模板管理" href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" mce_href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试题类型管理" href="ExamManagement/ExaminationType/ExaminationInformation.aspx" mce_href="ExamManagement/ExaminationType/ExaminationInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试题题目管理" href="ExamManagement/ExamQuestion/QuestionInformation.aspx" mce_href="ExamManagement/ExamQuestion/QuestionInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="考试申请管理" href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" mce_href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷下载管理" href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" mce_href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷删除管理" href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" mce_href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" roles="超级管理员,系统管理员" ></item>
</submenu>
<submenu id="5" text="报表信息管理">
<item text="缓考补考报表" href="ReportInformation/StudentExamState/StudentExamState.aspx" mce_href="ReportInformation/StudentExamState/StudentExamState.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
<item text="校区考试报表" href="ReportInformation/ExamGrade/ExamGradeReport.aspx" mce_href="ReportInformation/ExamGrade/ExamGradeReport.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任,校区考试专员" ></item>
<item text="班级课程报表" href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" mce_href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
</submenu>
<submenu id="6" text="日志操作管理">
<item text="登陆日志管理" href="LoginManagement/LogLogins.aspx" mce_href="LoginManagement/LogLogins.aspx" roles="超级管理员" ></item>
<item text="操作日志管理" href="LoginManagement/LogOpeations.aspx" mce_href="LoginManagement/LogOpeations.aspx" roles="超级管理员" ></item>
<item text="日志导出" href="LoginManagement/ErportLog.aspx" mce_href="LoginManagement/ErportLog.aspx" roles="超级管理员" >
</item>
</submenu>
<submenu id="7" text="个人信息管理">
<item text="个人资料修改" href="PersonalManagement/PersonalManagement.aspx" mce_href="PersonalManagement/PersonalManagement.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
</submenu>
</menu>
defatult.aspx.cs文件代码
[c-sharp] view
plaincopy
XmlDocument x = new XmlDocument();//实例化一个XML文档
protected void Page_Load(object sender, EventArgs e)
{
XMLopertator();
}
/// <summary>
/// 循环读取XML里的内容
/// </summary>
public void XMLopertator()
{
XMLLoad();
XmlNodeList xnl=x.ChildNodes;
foreach (XmlNode xn in xnl)
{
XmlNodeList xnl1 = xn.ChildNodes;
foreach (XmlNode xn1 in xnl1)
{
XmlNodeList xnl2 = xn1.ChildNodes;
foreach (XmlNode xn2 in xnl2)
{
Response.Write(xn2.Attributes["text"].Value+"<br/>");
}
}
}
}
/// <summary>
/// 加载XML文档
/// </summary>
public void XMLLoad()
{
x.Load(Server.MapPath("~/Left.xml"));
}
转载自:点击打开链接
做起来很简单 的
[xhtml] view
plaincopy
<?xml version="1.0" encoding="utf-8" ?>
<menu>
<submenu id="1" text="校区基本信息">
<item text="校区管理" href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" mce_href="SchoolBaseSet/SchoolManagement/SchoolInformation.aspx" roles="超级管理员,系统管理员,院校长"></item>
<item text="班级管理" href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" mce_href="SchoolBaseSet/ClassManagement/ClassInformation.aspx" roles="超级管理员,系统管理员,班主任,院校长,教学主管,教学主任,校区考试专员" ></item>
<item text="学生信息管理" href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" mce_href="SchoolBaseSet/StudentInformation/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
<item text="用户信息管理" href="SchoolBaseSet/UserManagement/UserInformation.aspx" mce_href="SchoolBaseSet/UserManagement/UserInformation.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任"></item>
<item text="教师审批管理" href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" mce_href="SchoolBaseSet/TeacherPass/TeacherPass.aspx" roles="教学主管,教学主任,校区考试专员"></item>
<item text="切换教师角色" href="SchoolBaseSet/TeacherPass/RolesChange.aspx" mce_href="SchoolBaseSet/TeacherPass/RolesChange.aspx" roles="校区考试专员"></item>
</submenu>
<submenu id="2" text="学生成绩管理">
<item text="成绩综合管理" href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentGradeAll.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
<item text="学生成绩管理" href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" mce_href="StudentGradeManagement/StudentGradedescirption/StudentInformation.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任" ></item>
</submenu>
<submenu id="3" text="数据字典设置">
<item text="专业管理" href="DataDictionary/Specialty/Specialties.aspx" mce_href="DataDictionary/Specialty/Specialties.aspx" roles="超级管理员,系统管理员" ></item>
<item text="课程管理" href="DataDictionary/Course/Courses.aspx" mce_href="DataDictionary/Course/Courses.aspx" roles="超级管理员,系统管理员" ></item>
<item text="专业课程管理" href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" mce_href="DataDictionary/CourseInSpecialty/CouserInSpecialty.aspx" roles="超级管理员,系统管理员" ></item>
<item text="角色管理" href="DataDictionary/Rolse/Roles.aspx" mce_href="DataDictionary/Rolse/Roles.aspx" roles="超级管理员"></item>
<item text="管理员管理" href="DataDictionary/AdminUser/AdministratorUser.aspx" mce_href="DataDictionary/AdminUser/AdministratorUser.aspx" roles="超级管理员" ></item>
<item text="Logo图标管理" href="DataDictionary/Logo/EditLogo.aspx" mce_href="DataDictionary/Logo/EditLogo.aspx" roles="超级管理员,系统管理员,教学主管,教学主任" ></item>
<item text="学号长度设置" href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" mce_href="DataDictionary/StudentCodeSet/StudentCodeLenghtInf.aspx" roles="超级管理员,系统管理员" ></item>
<item text="恢复设置管理" href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" mce_href="DataDictionary/RemoveSchool/RemoveAllSchool.aspx" roles="超级管理员" ></item>
</submenu>
<submenu id="4" text="考试操作管理">
<item text="考试类型管理" href="ExamManagement/ExamType/ExamTypeInformation.aspx" mce_href="ExamManagement/ExamType/ExamTypeInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷模板管理" href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" mce_href="ExamManagement/ExamTemplate/ExamTemplateInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试题类型管理" href="ExamManagement/ExaminationType/ExaminationInformation.aspx" mce_href="ExamManagement/ExaminationType/ExaminationInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试题题目管理" href="ExamManagement/ExamQuestion/QuestionInformation.aspx" mce_href="ExamManagement/ExamQuestion/QuestionInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="考试申请管理" href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" mce_href="ExamManagement/ExamApplication/ExamApplicationInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷下载管理" href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" mce_href="ExamManagement/ExamDownLoad/ExamDownLoadInformation.aspx" roles="超级管理员,系统管理员" ></item>
<item text="试卷删除管理" href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" mce_href="ExamManagement/ExamPaperDelete/ExamPaperClear.aspx" roles="超级管理员,系统管理员" ></item>
</submenu>
<submenu id="5" text="报表信息管理">
<item text="缓考补考报表" href="ReportInformation/StudentExamState/StudentExamState.aspx" mce_href="ReportInformation/StudentExamState/StudentExamState.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
<item text="校区考试报表" href="ReportInformation/ExamGrade/ExamGradeReport.aspx" mce_href="ReportInformation/ExamGrade/ExamGradeReport.aspx" roles="超级管理员,系统管理员,院校长,教学主管,教学主任,校区考试专员" ></item>
<item text="班级课程报表" href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" mce_href="ReportInformation/StudentExamByClass/StudentExamReport.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
</submenu>
<submenu id="6" text="日志操作管理">
<item text="登陆日志管理" href="LoginManagement/LogLogins.aspx" mce_href="LoginManagement/LogLogins.aspx" roles="超级管理员" ></item>
<item text="操作日志管理" href="LoginManagement/LogOpeations.aspx" mce_href="LoginManagement/LogOpeations.aspx" roles="超级管理员" ></item>
<item text="日志导出" href="LoginManagement/ErportLog.aspx" mce_href="LoginManagement/ErportLog.aspx" roles="超级管理员" >
</item>
</submenu>
<submenu id="7" text="个人信息管理">
<item text="个人资料修改" href="PersonalManagement/PersonalManagement.aspx" mce_href="PersonalManagement/PersonalManagement.aspx" roles="超级管理员,系统管理员,院校长,班主任,教学主管,教学主任,校区考试专员" ></item>
</submenu>
</menu>
defatult.aspx.cs文件代码
[c-sharp] view
plaincopy
XmlDocument x = new XmlDocument();//实例化一个XML文档
protected void Page_Load(object sender, EventArgs e)
{
XMLopertator();
}
/// <summary>
/// 循环读取XML里的内容
/// </summary>
public void XMLopertator()
{
XMLLoad();
XmlNodeList xnl=x.ChildNodes;
foreach (XmlNode xn in xnl)
{
XmlNodeList xnl1 = xn.ChildNodes;
foreach (XmlNode xn1 in xnl1)
{
XmlNodeList xnl2 = xn1.ChildNodes;
foreach (XmlNode xn2 in xnl2)
{
Response.Write(xn2.Attributes["text"].Value+"<br/>");
}
}
}
}
/// <summary>
/// 加载XML文档
/// </summary>
public void XMLLoad()
{
x.Load(Server.MapPath("~/Left.xml"));
}
转载自:点击打开链接
做起来很简单 的
相关文章推荐
- asp.net 循环读取XML文档
- asp.net中XML文档的写入和读取,以及转化数据集相关实例
- 在.asp.net中读取xml文档
- ASP.Net中读取XML的方法总结
- 在asp.net中读取XML文件信息的4种方法
- ASP.NET中读取XML文件信息的4种方法与示例代码
- [ZT]关于ASP.NET读取XML新闻的问题
- ASP.NET中读取XML文件信息的4种方法与示例代码
- Asp.Net(C#)利用XPath解析XML文档示例
- 在asp.net中读取XML文件信息的4种方法
- asp.net 读取word 文档的方法
- 利用Asp.net Ajax异步获取xml文档内容
- [ASP.net]从数据库中读取数据自动生成XML
- ASP.NET学习小结(1)--Cookie,XML(建立xml文档,和查找一个结点)
- 利用Asp.net Ajax异步获取xml文档内容
- 刚注册,问个问题,在asp.net里有个xml文档以MemoryStream存在资源文件中,现在我如何把他读出来,还原成xml文档。
- ASP.NET中读取XML文件信息的4种方法与示例代码
- [ASP.net]从数据库中读取数据自动生成XML
- 在asp.net中如何用javascript读取本地Xml中的数据到网页中的文本框?
- 利用Asp.net Ajax异步获取xml文档内容