Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace \r\n Newlines using XSLT and .NET C# VS 2008
    text
    copied!<p>I use VS 2008, .net 3.5 for generate page html using XSLT.</p> <p>I have Message, that contains \r\n (newlines)</p> <p>I use this in XSL file:</p> <pre><code>&lt;b&gt;Message: &lt;/b&gt;&lt;xsl:value-of select="Message"/&gt;&lt;br/&gt; </code></pre> <p>I need replace \r\n by <code>&lt;br/&gt;</code> in xsl. I have seen several references but not get solution for my issue:</p> <p>I use this code C# before I call to transform XSLT, but not right:</p> <pre><code> m = m.Replace(@"\r\n", "&amp;#xD;&amp;#xA;"); m = m.Replace(@"\n", "&amp;#xA;"); //m = System.Web.HttpUtility.HtmlDecode(m); m = m.Replace(@"\r\n", "&lt;br/&gt;"); m = m.Replace(@"\n", "&lt;br/&gt;"); msg = "&lt;Exception&gt;" + "&lt;Description&gt;" + d + "&lt;/Description&gt;" + "&lt;Message&gt;" + m + "&lt;/Message&gt;" + "&lt;DateTime&gt;" + localTimeString + "&lt;/DateTime&gt;" + "&lt;/Exception&gt;"; </code></pre> <p>I use this references, but not solution</p> <p><a href="https://stackoverflow.com/questions/185101/interpreting-newlines-with-xslt-xsltext">Interpreting newlines with xsl:text?</a></p> <p><a href="https://stackoverflow.com/questions/1069092/xslt-replace-function-not-found">XSLT Replace function not found</a></p> <p>The replace function is only available in XSLT version 2.0, not in version 1.0 which is what Visual Studio uses. Just because you've specified version="2.0" doesn't mean that Visual Studio supports it.</p> <p>I use this like the last reference, but I get error:</p> <pre><code> &lt;xsl:call-template name="string-replace-all"&gt; &lt;xsl:with-param name="text" select="Message"/&gt; &lt;xsl:with-param name="replace" select="\r\n"/&gt; &lt;xsl:with-param name="by" select="&amp;lt;br/&amp;gt;"/&gt; &lt;/xsl:call-template&gt; </code></pre> <p>suggestions, any sample code works ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload