X

Removing additional whitespaces in your Elements and Attributes

Ramkumar Menon
Director, Product Strategy

In case your XML elements contain multiple whitespaces within the text, or leading and trailing the text, you could use normalize-space() function to remove the leading and trailing whitespaces, as well as to combine all adjacent intermediary whitespaces into one single whitespace.



For e.g



Input



<input>   1sp 2sp  3sp   4sp     5sp     3sp   end</input>



XSLT



 <ns1:result>
   <xsl:value-of select="normalize-space(/input)"/>
</ns1:result>



Result



<result>1sp 2sp 3sp 4sp 5sp 3sp end</result>

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.