Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outputing <div> statements to html using XSL/XML

Status
Not open for further replies.

iamzug

Technical User
Jan 5, 2005
1
GB
I want to get a drop down menu at the top of a page through XSL and XML. However I cannot output the div statements into the html page.

I want the following output:
<div id="menubar">
<div id ="name 1" class="menu">name 1<ul>
<li>subname 1</li>
<li>subname 2</li>
etc etc etc



But using the following XML and XSL I only get 'namesubnamesubnamenamesubname' etc. Can anybody help me?




XSL:
<xsl:variable name="menu">
<div id="menubar">
<xsl:for-each select="titles/category">
<xsl:variable name="categoryname"><xsl:value-of select="name"></xsl:value-of></xsl:variable>
<div id="{$categoryname}" class="menu"><xsl:value-of select="name" /><ul>
<xsl:for-each select="sub">
<xsl:variable name="subname">
<xsl:value-of select="subname" /></xsl:variable>
<li><xsl:value-of select="$subname" /></li>
</xsl:for-each>
</ul>
</div>
</xsl:for-each>
</div>
</xsl:variable>






XML:

<titles>
<category>
<name>name 1</name>
<sub>
<subname>subname 1</subname>
</sub>
<sub>
<subname>subname 2</subname>
</sub>
<sub>
<subname>subname 3</subname>
</sub>
</category>
<category>
<name>name 2</name>
<sub>
<subname>subname 1</subname>
</sub>
<sub>
<subname>subname 2</subname>
</sub>
</category>
<titles>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top