How to make a drop down menu using xslt and xml?



The problem is, when I save the code for the dropdown list in the .xsl file, after opening my .xml file in the browser I get the output of all the text from the .xml file appearing on the screen. All the output that I had before working on the dropdown list is gone and replaced by a massive block of text. I need the drop down list to appear with all the things I edited using xsl.


XML code for drop down list:



<selectlist>
<selectName num="1">
<memberName>Slash</memberName>
</selectName>
<selectName num="2">
<memberName>Axl</memberName>
</selectName>
<selectName num="3">
<memberName>Duff</memberName>
</selectName>
<selectName num="4">
<memberName>Izzy</memberName>
</selectName>
<selectName num="5">
<memberName>Steven</memberName>
</selectName>
<selectName num="6">
<memberName>Matt</memberName>
</selectName>
<selectName num="7">
<memberName>Gilby</memberName>
</selectName>
<selectName num="8">
<memberName>Ashba</memberName>
</selectName>
<selectName num="9">
<memberName>Josh</memberName>
</selectName>
<selectName num="10">
<memberName>Buckethead</memberName>
</selectName>
</selectlist>


XSL Code(the part in bold is responsible for drop down menu):



<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="text()">
<xsl:apply-templates/>
</xsl:template>


<xsl:for-each select="/selectlist/selectName">
<option VALUE="{memberName}">
<xsl:value-of select="memberName"/>
</option>
</xsl:for-each>

</xsl:stylesheet> `


Please excuse me if I actually haven't noticed something obvious, i'm just a beginner at web development, and xslt is giving me a hard time. Help will be much appreciated!


No comments:

Post a Comment