我想从包含 html 数据的一个字段的 xml 中获取普通文本。我无法在模板上设置条件。请建议我任何解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<workdetail>
<field name="summaryText1"><UL style="MARGIN-TOP: 0in" type=disc>
<LI style="TEXT-ALIGN: justify;MARGIN-BOTTOM: 0pt" class=MsoNormal><SPAN style="mso-fareast-font-family: 'timesnewroman'; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-style: italic"><FONT size=2>Manage the daily activities of the HOD s office.<?xml:namespace prefix = o /><o:p></o:p></FONT></SPAN></LI>
<LI style="MARGIN-BOTTOM: 0pt" class=MsoNormal><SPAN style="mso-fareast-font-family: 'timesnewroman'; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-style: italic"><FONT size=2>Handle and manage all communication, correspondence and filing of documents. <o:p></o:p></FONT></SPAN></LI>
<LI style="MARGIN-BOTTOM: 0pt" class=MsoNormal><SPAN style="mso-fareast-font-family: 'timesnewroman'; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-style: italic"><FONT size=2>Fix appointments, arrange for meetings, conferences etc.<o:p></o:p></FONT></SPAN></LI>
</workdetail>
mu xsl 文件为
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<workdetail>
<xsl:apply-templates select="*" />
</workdetail>
</xsl:template>
<xsl:template match="*:workdetail">
<xsl:variable name="text" select="*:field[starts-with(@name,'summaryText1')]"/>
<xsl:choose>
<xsl:when test="contains($text, '<')">
<xsl:value-of select="substring-after($text, '<')"/>
<xsl:variable name="text" select="substring-after($text, '>')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:stylesheet>
这将返回 > 标签之后的所有内容。我可以在其中传递更多的值,这将只返回文本文档。