Code and version: .NET Framework 3.5 // vb.net
How I can keep the line break of a string field? The line break is saved in the database with Environment.NewLine
Original string with newline
this is line 1
this is line 2
this is line 3
I am tried the next codes, but no success:
Dim ws As New XmlWriterSettings()
ws.NewLineHandling = NewLineHandling.Entitize
Dim ser As New XmlSerializer(GetType(Facturae))
Using wr As XmlWriter = XmlWriter.Create(_ficheroXML, ws)
ser.Serialize(wr, fac)
End Using
or
Dim serializer As New XmlSerializer(GetType(Facturae))
Dim xtw As XmlTextWriter = New XmlTextWriter(New StreamWriter(_ficheroXML, False))
serializer.Serialize(xtw, fac)
xtw.Flush()
xtw.Close()
xml output:
<ItemDescription>this is line 1 this is line 2 this is line 3</ItemDescription>