Producing a new line in XSLT xslt I want to produce a newline for text output in XSLT. Any ideas? Best Answer The following XSL code will produce a newline (line feed) character: <xsl:text>
</xsl:text> For a carriage return, use: <xsl:text>
</xsl:text> Related SolutionsC# – How to apply an XSLT Stylesheet in C# I found a possible answer here: http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63 From the article: XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ; XslTransform myXslTrans = new XslTransform() ; myXslTrans.Load(myStyleSheet); XmlTextWriter myWriter = new XmlTextWriter("result.html",null) ; myXslTrans.Transform(myXPathDoc,null,myWriter) ; Edit: But my trusty compiler says, XslTransform is obsolete: Use XslCompiledTransform instead: XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ; XslCompiledTransform myXslTrans = new XslCompiledTransform(); myXslTrans.Load(myStyleSheet); XmlTextWriter myWriter = new XmlTextWriter("result.html",null); myXslTrans.Transform(myXPathDoc,null,myWriter); How to insert in XSLT Use the entity code   instead. is a HTML "character entity reference". There is no named entity for non-breaking space in XML, so you use the code  . Wikipedia includes a list of XML and HTML entities, and you can see that there are only 5 "predefined entities" in XML, but HTML has over 200. I'll also point over to Creating a space ( ) in XSL which has excellent answers. Related TopicXml – new line character in xsltXml – How to implement if-else statement in XSLTNot adding new line in the XSLT
Best Answer
The following XSL code will produce a newline (line feed) character:
For a carriage return, use: