Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSLT只打印第一个字母_Xml_Xslt - Fatal编程技术网

Xml XSLT只打印第一个字母

Xml XSLT只打印第一个字母,xml,xslt,Xml,Xslt,是否可以打印两个xml标记之间的第一个字母。例如,如果您有如下xml代码: <?xml version="1.0" encoding="UTF-8"?> <!-- Edited by XMLSpy --> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country&g

是否可以打印两个xml标记之间的第一个字母。例如,如果您有如下xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited by XMLSpy -->
<catalog>
<cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
</cd>
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/">
     <html>
     <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <tr>
        <td><xsl:value-of select="catalog/cd/title"/></td>
        <td><xsl:value-of select="catalog/cd/artist"/></td>
      </tr>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
而不是:

My CD Collection
    Title                      Artist
    Empire Burlesque           Bob Dylan

学习XPath字符串函数,如并使用
子字符串(title,1,1)

My CD Collection
    Title                      Artist
    Empire Burlesque           Bob Dylan