JavaScript XSLT Demo

Input XML

	<student_list>
		<student>
			<name>George Washington</name>
			<major>Politics</major>
			<phone>312-123-4567</phone>
			<email>gw@example.edu</email>
		</student>
		<student>
			<name>Janet Jones</name>
			<major>Undeclared</major>
			<phone>311-122-2233</phone>
			<email>janetj@example.edu</email>
		</student>
		<student>
			<name>Joe Taylor</name>
			<major>Engineering</major>
			<phone>211-111-2333</phone>
			<email>joe@example.edu</email>
		</student>
	</student_list>
	

XSLT Stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
<xsl:output method="html"/> 
 
<xsl:template match="/"> 
<html> 
	<body> 
	<xsl:apply-templates /> 
	</body> 
</html> 
</xsl:template> 
 
<xsl:template match="student_list"> 
	<h3>Student Directory for example.edu</h3> 
	<xsl:apply-templates /> 
</xsl:template> 
 
<xsl:template match="name"> 
	<p>Name: <xsl:apply-templates /></p> 
</xsl:template> 
 
<xsl:template match="major"> 
	<p>Major: <xsl:apply-templates /></p> 
</xsl:template> 
 
<xsl:template match="phone"> 
	<p>Phone: <xsl:apply-templates /></p> 
</xsl:template> 
 
<xsl:template match="email"> 
	<p>Email: <xsl:apply-templates /></p> 
</xsl:template> 
 
</xsl:stylesheet>
	

Output