XML读取及网页显示

 

 

例题:学生成绩的XML文档

<?xml version="1.0" encoding="gb2312"?>

<students>

       <student id="05001">

                     <name>张三</name>

                     <dept>计算机</dept>

                     <course id="001">

                            <title>C程序设计</title>

                            <score>85</score>

                      <date>2000/12/04</date>

                     </course>

                     <course id="002">

                            <title>编译方法</title>

                            <score>79</score>

                      <date>2000/12/06</date>

                     </course>

                     <course id="003">

                            <title>数据结构</title>

                            <score>93</score>

                      <date>2000/12/10</date>

                     </course>

       </student>

       <student id="05002">

                     <name>李四</name>

                     <dept>数学</dept>

                     <course id="004">

                            <title>计算方法</title>

                            <score>95</score>

                      <date>2000/12/04</date>

                     </course>

                     <course id="005">

                            <title>偏微分方程</title>

                            <score>86</score>

        <date>2000/12/07</date>

                     </course>

                     <course id="006">

                            <title>计算复杂性</title>

                            <score>72</score>

                      <date>2000/12/03</date>

                     </course>

       </student>

       <student id="05003">

                     <name>王五</name>

                     <dept>化学</dept>

                     <course id="007">

                            <title>有机化学</title>

                            <score>80</score>

                      <date>2000/12/09</date>

                     </course>

                     <course id="008">

                            <title>无机化学</title>

                            <score>98</score>

                      <date>2000/12/15</date>

                     </course>

                     <course id="009">

                            <title>分子轨道理论</title>

                            <score>79</score>

                      <date>2000/12/23</date>

                     </course>

                     <course id="010">

                            <title>分子生物学</title>

                            <score>88</score>

                      <date>2000/11/27</date>

                     </course>

       </student>

</students>

 

请利用XMLDOM和XSLT编写如下的网页, 通过选择姓名来动态显示每个学生的成绩单。

请给出网页的代码和运行效果的截屏。

要求效果图:

 

 

 

关于xml,xsl,html几者之间的关系以及调用就不再赘述,直接上源码与效果图。

 

Xml部分:

 

 

Xsl部分:

Html部分:

 

Loadxmldoc.js部分(就是默认用法了):

 

 

运行效果截图:

 

 

posted @ 2019-01-14 11:26  STK0210  阅读(3142)  评论(0编辑  收藏  举报