Link to home
Start Free TrialLog in
Avatar of Boopathy S
Boopathy SFlag for India

asked on

Need to remove empty space <p> Tag

I want to remove the empty space <p> element using XSL:

XML I'm having:

        <Body>
          <p> </p>
          <h1>AAA</h1>
       <p>aaa</p>
      </Body>

XSL I Used:

   <xsl:strip-space elements="p"/>

   <xsl:template match="Body">
      <xsl:copy>
         <h1><xsl:value-of select="h1[normalize-space()]" separator=" "/></h1>
         <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="h1"/>

   <xsl:template match="p[not(normalize-space())]"/>

Output I'm getting like:

        <Body>
          <h1>AAA</h1>
              <p> </p>
              <p>aaa</p>
            </Body>

Expected output be like:

        <Body>
          <h1>AAA</h1>
              <p>aaa</p>
            </Body>
            
Need to remove the empty space para tags. Please suggest code. Thanks in advance
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

I think the approach from my response in your previous question is exactly what you need
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Boopathy S

ASKER

Thanks