|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How can XSL transform XHTML data into fragments?
Hi,
I wonder if anyone know how to use XSL to transform an XHTML file that contains certain blocks of text within the <td> tags, for example: <td valign="TOP" align="LEFT" bgcolor="#FFFFFF" width="260" class="WhiteBackBlackText">Is London the best place?</td> where I try to extract "Is London the best place?" to a data section named "<tag>", so that the result will be: <tag>Is London the best place?</tag> I know you can do certain apply-templates functions, but just do not know how I can get the data from an XHTML extract such as a piece of table data within a table. The following code will get me back all the text of all the table data fragments that exists to put into the <tag></tag> section. <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <root> <xsl:apply-templates select="table/tr"/> </root> </xsl:template> <xsl:template match="td"> <tag><xsl:value-of select="." /></tag> </xsl:template> </xsl:stylesheet> Am I on the right lines? Last edited by lamwh : April 26th, 2004 at 04:17 AM. Reason: Changed title and make content more precise. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL to transform XHTML data into fragments |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|