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

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.