|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML element's data to HTML attribute's data with XSLT
Alright...I have the following element in my XML file: <loc> some url </loc>. It refers to the location of an <image></image>. How can I take the <loc>'s data and transform it into <img src=" the url inside <loc>"/> (the 'src' attribute's data) when transforming the XML file into HTML with XSLT. Thank you.
|
|
#2
|
|||
|
|||
|
Here is an example of one way of doing it:
Code:
<?xml version="1.0"?> <root> <loc>/images/image1.gif</loc> </root> Code:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<img>
<xsl:attribute name="src"><xsl:value-of select="/root/loc"/></xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XML element's data to HTML attribute's data with XSLT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|