首页 > 解决方案 > How do I search and remove text using XSLT?

问题描述

I need to search and remove this span <span property="atom:tag" class="ktp-meta">nclex_rn_qbank</span> from the HTML below using XSLT. How would I do that?

My script is setup to only make this change on certain files, not all so I can't do a simple search and replace in all files.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" designation="" enumeration="">
    <head>
        <meta charset="utf-8" />
        <link type="text/css" rel="stylesheet" title="default" href="../../assets/css/main.css" />
        <title>n002001_ORG</title>
    </head>
    <body>
        <ol class="ktp-question-set">
            <li property="ktp:question" typeof="ktp:Question" class="ktp-question">
                <section class="ktp-question-meta">
                    <section property="ktp:metadata" class="ktp-meta">
                        <span property="atom:content-item-name" class="ktp-meta"
                            data-value="n002001_ORG"></span>
                    </section>
                    <section property="ktp:tags" class="ktp-meta">
                        <span property="ktp:interactionType" class="ktp-meta">single-select</span>
                        <span property="atom:tag" class="ktp-meta">nursing</span>
                        <span property="atom:tag" class="ktp-meta">nclex_rn</span>
                        <span property="atom:tag" class="ktp-meta">nclex_rn_qbank</span>           
                    </section>
                </section>  
            </li>
        </ol>
    </body>
</html>

标签: xslt

解决方案


你有没有试过这样:

<xsl:template match="span[@property='atom:tag' and @class='ktp-meta' and normalize-space(.) = 'nclex_rn_qbank']"/>

推荐阅读