如何从 GSA 结果中删除摘要字段中的 html 标签?

How to remove html tags in summary field from the results of GSA?

使用 JAPI-GSA,我在每个摘要中收到来自结果 GSA 的 html 标签。 高手 "summary": "... 此票价不适用于独自旅行的儿童 (UM)。最低
票价,其他票价,单程航班:巴黎-瓜拉吉隆坡... "

如何从摘要中删除这些标签。 提示:我需要修改 XSLT

GSA 抛出的原始搜索结果在 XML 中。在此 XML 输出中,片段在一定数量的字符后包含标签。您无法编辑 XML 输出,但就像您暗示的那样,您可以修改 XSLT。

在 XSLT 文件中,添加以下模板:

<!-- **********************************************************************
REMOVE BR LINE-BREAKS FROM SNIPPETS
********************************************************************** -->

  <xsl:template name="remove_br">
    <xsl:param name="orig_string"/>

  <xsl:variable name="removed_br">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find">&lt;br&gt;</xsl:with-param>
      <xsl:with-param name="replace"> </xsl:with-param>
      <xsl:with-param name="string" select="$orig_string"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of disable-output-escaping='yes' select="$removed_br"/>
</xsl:template>

此模板查找标签并将其替换为白色 space。添加此模板后,找到正在创建代码段框的部分并将其替换为以下代码段:

<!-- *** Snippet Box *** -->
<table cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td class="s">

    <xsl:if test="$show_res_snippet != '0' and string-length(S) and
                    $only_apps != '1'">
        <xsl:variable name="snippet">
          <xsl:call-template name="remove_br">
            <xsl:with-param name="orig_string" select="S"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="reformat_keyword">
          <xsl:with-param name="orig_string" select="$snippet"/>
        </xsl:call-template>
      </xsl:if>

此代码调用您之前添加的模板并生成一个代码段,其中标签被替换为白色 space。