xml/xsl(1):简单使用XSL显示XML样例

前端之家收集整理的这篇文章主要介绍了xml/xsl(1):简单使用XSL显示XML样例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

test1.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>

<teams>
	<team>
		<mankind>tangsheng</mankind>
		<monkey>wukong</monkey>
		<pig>bajie</pig>
		<celestial>sasheng</celestial>
		<horse>bailong</horse>
	</team>
</teams>


test1.xsl
<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
	
	<h2>
		Description of teams...............
	</h2>
	
	<body>
		<table width="100%" border="1dpx" class="table table-striped mt40">
			<tr bgcolor="#5cacee">
				<td align="left">Mainkind</td>
				<td align="left">Monkey</td>
				<td align="left">Pig</td>
				<td align="left">celestial</td>
				<td class="last-col" align="left">Horse</td>
			</tr>
		
		<xsl:for-each select="teams/team">
			<tbody>
			<tr>
				<td><xsl:value-of select="mankind"/></td>
				<td><xsl:value-of select="monkey"/></td>
				<td><xsl:value-of select="pig"/></td>
				<td><xsl:value-of select="celestial"/></td>
				<td><xsl:value-of select="horse"/></td>
			</tr>
			</tbody>
		</xsl:for-each>
		</table>
    </body>
</html>

</xsl:template>
</xsl:stylesheet>
呵呵。。 原文链接:https://www.f2er.com/xml/298776.html

猜你在找的XML相关文章