实名认证用户熊川湘 身份证号码430811198506290914

学习使用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>

这么写无效啊!求高人!

 

posted @ 2013-04-26 16:56  浪达短信群发  阅读(268)  评论(0编辑  收藏  举报