【实验目的】
掌握CSS格式化XML输出的一般设计。
【实验环境】
VS.NET
【设计参考】
- 设计XML文件
- 设计CSS文件
- 运行效果
源代码如下:
a.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="b.css"?>
<xml>
<TITLE0>五言绝句</TITLE0>
<poetry>
<TITLE>静夜思</TITLE>
<author>李白</author>
<content>
<verse>床前明月光,疑是地上霜。</verse>
<verse>举头望明月,低头思故乡。</verse>
</content>
</poetry>
<poetry>
<TITLE>登鹳雀楼</TITLE>
<author>王之涣</author>
<content>
<verse>白日依山尽,黄河入海流。</verse>
<verse>欲穷千里目,更上一层楼。</verse>
</content>
</poetry>
<poetry>
<TITLE>相思</TITLE>
<author>王维</author>
<content>
<verse>红豆生南国,春来发几枝。</verse>
<verse>愿君多采撷,此物最相思。</verse>
</content>
</poetry>
</xml>
b.css
TITLE0
{
display: block;
font-size: 19pt;
font-weight: bold;
text-align: center;
}
TITLE
{
display: block;
font-size: 17pt;
font-weight: bold;
text-align: center;
text-decoration:underline;
}
poetry
{
display: block;
text-align:center;
font-size: 18pt;
font-weight: bold;
background-color: bisque;
border-style: solid;
border-width: thick;
border-color: beige;
}
author{
display: block;
font-size: 16pt;
font-style: italic;
}
verse{
display: block;
font-size: 9pt;
font-weight: bold;
}
运行结果: