dpi96151 2016-11-24 13:51
浏览 42

XSL取代P标签

I have a variable in XML which I would like to format. In variable, it's HTML with tags. Our system produces too many p tags, so I would like to remove all <p> and closing </p>. There is text in between p tags, which I want to stay, just remove p and /p tags.

 <xsl:value-of select="php:functionString('str_replace',$remove,'',normalize-space(php:functionString('html_entity_decode',description)))" />

I've tried with this, but this just removes one p and not closing one.

What is the best solution?

Here is the whole template. How i can implement it: thank you for your answer. I completely new to XSL and i didn't managed to get it to work. Here is my the section of the code. I would like to remove p tag from variable description.

<xsl:stylesheet version="1.0"     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>

<xsl:template match="/">

<products>
<xsl:for-each select="objects/object">
<xsl:element name="name"><xsl:value-of select="name"/></xsl:element>
<xsl:element name="url"><xsl:value-of select="product_url"/></xsl:element>
<xsl:element name="description"><xsl:value-of select="description"/>           </xsl:element>
</products>
</xsl:template>
</xsl:stylesheet>
  • 写回答

2条回答 默认 最新

  • dqz7636 2016-11-24 16:26
    关注

    Is there a problem with following solution:

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

    So you will match p-tags and will only process their child nodes, like e.g. text and tags.

    评论

报告相同问题?

悬赏问题

  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒