学习使用xls显示xml

<?xml version="1.0" encoding="utf-8"?>
<!--element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.-->
<!-- 不能放在本文的第一行  -->
<?xml-stylesheet type="text/xsl" href="simple.xsl"?><!-- processing-instruction-->
<bookstore ><!--root node-->
<books ><!--<books xmlns:xsl="http://www.w3.org/1999/XSL/Transform" namespace comment-->
    <book category="COOKING"><!--category="COOKING" attribute-->
      <title lang="en">Everyday Italian<!--text--></title>
      <author>Giada De Laurentiis</author>
      <year>2005</year>
      <price>30.00&lt; &gt; &amp; &apos; &quot;</price>
    </book>
</books>
<discs><!--element-->
    <disc> <!--element-->
      <name>discsname</name>
      <songster>
      <![CDATA[
 &lt;     <     less than
&gt;     >     greater than
&amp;     &     ampersand
&apos;     '     apostrophe
&quot;     "     quotation mark
]]>
      </songster>
      <price>130.00</price>
    </disc>
</discs>  
</bookstore>

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
  <body style="font-family:Arial,helvetica,sans-serif;font-size:12pt;
        background-color:#EEEEEE">
    <xsl:for-each select="bookstore/books/book">
      <div style="background-color:teal;color:white;padding:4px">
        <span style="font-weight:bold;color:white">
        <xsl:value-of select="author"/></span>
        - <xsl:value-of select="price"/>
      </div>
      <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
        <xsl:value-of select="title"/>
        <span style="font-style:italic">
          (<xsl:value-of select="year"/> calories per serving)
        </span>
      </div>
    </xsl:for-each>
   
     <xsl:for-each select="bookstore/discs/disc">
      <div style="background-color:teal;color:white;padding:4px">
        <span style="font-weight:bold;color:white">
        <xsl:value-of select="name"/></span>
        -<xsl:value-of select="songster"/>- <xsl:value-of select="price"/>
      </div>
    </xsl:for-each>
  </body>
</html>

 

xsl怎么读取xml属性值?

<author>

<name sex="male">小禹</name>

<name sex="female">春华</name>

<name sex="female">秋实</name>

</author>

我想要通过xsl显示sex里面的值

<xsl:for-each select="author/name">

<xsl:value-of select="@sex"/></li>


</xsl:for-each>

这么写无效啊!求高人!

 

转载于:https://www.cnblogs.com/wzg0319/archive/2013/04/26/3045222.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值