-1

I have a HTML document in which there is a <td> tag
In this td tag the TextContent is equal to "Type"
It is not neccessary that the td tag directly has content,it may have content in the subtags.

The "Type" stuff may be enclosed in between the spaces

What will be the XPath expression for the same?

<td align="left" style="background-color:#648190;"><span style="color:#ffffff;font-family:arial;font-size:small;"><b>   Type</b></span></td>

Thanks in advance

CSJakharia

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by fpmurphy
0

Assuming the following example HTML file as input

<html>
<head></head>
<body>
<td align="left" style="background-color:#648190;"><span style="color:#ffffff;font-family:arial;font-size:small;"><b>   Type</b></span></td>
<td align="left" style="background-color:#648190;"> Value</td>
</body>
</html>

The following stylesheet will output the node-set containing the string "Type" in any text node.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xsl:output method="xml"/>

   <xsl:template match="/html//td">
      <xsl:if test=".//text()[contains(., 'Type')]">
         <xsl:copy-of select="." />
      </xsl:if>
   </xsl:template>

   <xsl:template match="/">
      <xsl:apply-templates select="/html//td" />
   </xsl:template>

</xsl:stylesheet>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.