|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hi -
Let's say i have this XML: <content> <para>bla bla bla bla bla bla <link url="http://jeof.net">link name</link> bla bla bla</para> <para>yada yada yada</para> </content> Now - I want to create a anchor/link inside the body of the paragraph using the URL in the attribute - but how do I get the value of the attribute?? Here's one thing I've done: <xsl:template match="content"> <xsl:for-each select="p"> <p><xsl:apply-templates /></p> </xsl:for-each> </xsl:template> <xsl:template match="p//link"> <a href=""> <xsl:value-of select="."/> </a> </xsl:template> And it generates the paragraph just fine - but I need to get the value of the url attribute from the <link> element in my XML into the href attribute of the outputted HTML. How? thanks |
|
#2
|
|||
|
|||
|
I think this will do what you want:
Code:
<xsl:template match="content"> <xsl:for-each select="p"> <p><xsl:apply-templates /></p> </xsl:for-each> </xsl:template> <xsl:template match="p//link"> <a> <xsl:attribute name="href"> <xsl:value-of select="@url"/> </xsl:attribute> <xsl:value-of select="."/> </a> </xsl:template> Hope that helps!
__________________
- MW |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > getting attribute from element with XSL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|