Jump to content
  • Advertisement
Sign in to follow this  

[web] href in xslt from xml file

This topic is 4866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings all, I'm just trying to solve a problem here at work and I've never been able to work out how to do it while playing around previously so thought I'd check here :). Given an xml file such as
        <Recorded>20/09/2005 10:04:46 AM</Recorded>
        <Uploaded>21/11/2005 9:50:40 AM</Uploaded>

and an xslt of
<xsl:stylesheet version="1.0"

<xsl:template match="/">
        This is an XSLT template file. Fill in this area with the
        XSL elements which will transform your XML to XHTML.

		<xsl:apply-templates select="//Channel" />

<xsl:template match="Channel">
		<u><xsl:value-of select="Name"/></u>
	<xsl:apply-templates select="Show" />	
<xsl:template match="Show">
	<xsl:apply-templates select="Title" />
	<hr />
	Recorded: <xsl:apply-templates select="Recorded" /><br />
	Duration: <xsl:apply-templates select="Duration" /> Minutes<br />
	<p />
	Description: <xsl:apply-templates select="Description" /><p />
<xsl:template match="*">
	<xsl:value-of select="." />

My question is, how would I go about using the linnk node as a href around the title node. I've tried various permutations of something like
<a href=<xsl:apply-templates select="link">><xsl:apply-templates select="Title"></a>

but as expected it doesn't work so any help would be most appreciated. I'm currently doing this using the xml object in asp 2.0 c# but if I can only do it using XPath or similar then I have no issues with changing if it's quick enough...damn deadlines :)

Share this post

Link to post
Share on other sites
<a href=<xsl:apply-templates select="link">><xsl:apply-templates select="Title"></a>

That's not valid XML. Use the element and attribute elements in the XSLT namespace to create the anchor tag.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!