通过使用XSL,您可以向XML文档添加显示信息。
使用XSL显示XML
XSL是首选的XML样式表语言。
XSL远比CSS更加完善。使用XSL的方法之一是在浏览器显示XML文件之前,先把它转换为HTML,正如以下的这些例子演示的那样:
查看XML文件:
以下为引用的内容:
-
-
-
Belgian Waffles
$5.95
two of our famous Belgian Waffles with plenty of real maple syrup
650
-
Strawberry Belgian Waffles
$7.95
light Belgian waffles covered with strawberries and whipped cream
900
-
Berry-Berry Belgian Waffles
$8.95
light Belgian waffles covered with an assortment of fresh berries and whipped cream
900
-
French Toast
$4.50
thick slices made from our homemade sourdough bread
600
-
Homestyle Breakfast
$6.95
two eggs, bacon or sausage, toast, and our ever-popular hash browns
950
XSL样式表:
以下为引用的内容:
-
-
-
-
-
-
-
-
-
(
calories per serving)
查看结果。
下面是此XML文件的一个片断。 第二行,<?xml-stylesheet type="text/xsl" href="simple.xsl"?>,把这个XML文件链接到XSL文件:
以下为引用的内容:
Belgian Waffles
$5.95
two of our famous Belgian Waffles
650
如果你需要学习更多有关XSL的知识,请访问我们的《XSL教程》。