现在的位置: 首页 > 综合 > 正文

xml学习笔记—1

2012年10月04日 ⁄ 综合 ⁄ 共 884字 ⁄ 字号 评论关闭

寒假看了几天xml,几天来调试,一个小问题两个小时才解决,就是下面这行:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

需要说明的是注意这个namespace的大小写以及内容,我想这应该是固定的;

下面是调试成功的示例代码:

xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">

<html>
<body>
  <xsl:for-each select="breakfast/food">
   <div style="background-color:#777777;color:#ffffff;padding:4px">
    <span style="font-weight:bold;color:#ffffff">
     <xsl:value-of select="name"/>
    </span>
    jiage:<xsl:value-of select="price"/>
  <xsl:value-of select="calories"/>
   </div>
   
   </xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

xml:

<?xml version="1.0"?>
<!--File Name:XslDemo01.xml -->
<?xml-stylesheet type="text/xsl" href="make.xsl"?>
<breakfast>
  <food>
   <name>pizza</name>
    <price>$5</price>
    <calories>900</calories>
  </food>
  <food>
   <name>jiaozi</name>
    <price>$100</price>
    <calories>100</calories>
  </food>
</breakfast>

抱歉!评论已关闭.