3

I am having a string which is multiline in content and I use br tag or "\n" or Environment.newLine for it. Which I finally assign to XMLwriter like

writer.WriteElementString("FINALDESTINATION", valFinalDest);

But after loading the xsl file and writing my html using XmlTextWriter I loose the new line in the resulting html file. Is there any way I could retain the newline in the resulting html file.

Using br tags results in inline br tags in the html, while environment.newline and "\n" does not renders the final html with multiline content but in a single line.

Kirill Polishchuk
  • 54,804
  • 11
  • 122
  • 125
Vinay
  • 471
  • 3
  • 8
  • 19
  • see also http://stackoverflow.com/questions/2700435/writing-xmldocument-to-file-with-specific-newline-character-c – Tomas Walek Oct 18 '11 at 13:57

3 Answers3

1

You have 2 options:

  1. Replace new line with br, p, div, etc.
  2. Put content inside pre element, which preserves both spaces and line breaks.
Kirill Polishchuk
  • 54,804
  • 11
  • 122
  • 125
0

Use XML CDATA.

qJake
  • 16,821
  • 17
  • 83
  • 135
  • stringvalue = "<![CDATA[" + stringvalue + "]]>" in code was resulting the html to have cdata as text included it. And if I was using it in xsl file then it was giving the xsl format as the output. – Vinay Oct 18 '11 at 14:21
0

Set the property Indent of the object of type XmlWriterSettings to true and pass this object to the XmlWriter.Create method as second parameter.

Tomas Walek
  • 2,516
  • 2
  • 23
  • 37