Pooja
Pooja

Reputation: 495

how to check if the tag contains sepcfic string in xslt

I am using XSLT with C#.

My input tag is in the format like

<td>....</td>
<td>uma</td>

I need to convert td to entry tag and check if it contains the following sequence ... so my output will be as follow.

 <entry></entry>
<entry>uma</entry> 

How to check if the tag contains only ... and replace with empty. Tag always contains ..., it is static.

Upvotes: 1

Views: 699

Answers (2)

Maestro13
Maestro13

Reputation: 3696

Try the following

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <root>
            <xsl:apply-templates/>
        </root>
    </xsl:template>

    <xsl:template match="td">
        <entry>
            <xsl:if test=". != '...'">
                <xsl:value-of select="."/>
            </xsl:if>
        </entry>
    </xsl:template>

</xsl:stylesheet>

Upvotes: 2

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56212

You can check this condition using

td[text() = '...']

Upvotes: 1

Related Questions