Hi, i’m new to this library and i don’t know to make my created html document had new line character. this is my code : ` string outFile = @“c:\result_Soap_Request.html”;
// Initialize an empty HTML document
using (var htmldocument = new HTMLDocument())
{
// Create a text element to add to the HTML document
var machineState = htmldocument.CreateTextNode("Machine state : "+ d.ContatoreTot2);
var currentSpeedActualFrequence = htmldocument.CreateTextNode("Machine actual frequency : " + d.FrequenzaAttualeMacch + " ");
var currentSpeedActualVelocity = htmldocument.CreateTextNode("Machine actual velocity : " + d.VelocitaFilmAttuale + " ");
var cycleCounter = htmldocument.CreateTextNode("Cycle counter : " + d.ImpNumCicli + " ");
// Add text element to HTML body
htmldocument.Body.AppendChild(machineState);
htmldocument.Body.AppendChild(currentSpeedActualFrequence);
htmldocument.Body.AppendChild(currentSpeedActualVelocity);
htmldocument.Body.AppendChild(cycleCounter);
// Save the HTML file to a disk
htmldocument.Save(outFile);
}`
I had tried all solutions , adding ‘\n’, adding the
tag in the string, using 
 for new line but none of them has worked. Can somebody help me?
Thanks in advance
@Carlone22
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): HTMLNET-4382
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
1 Like
Thanks for the reply. I have already solve my problem always using Aspose but with streamWriter and MemoryStream. Thanks a lot anyways!
@Carlone22
Thanks for your feedback and it is good to know that your issue has been resolved. The content of the string passed to the CreateTextNode method is treated as text, not as HTML. Therefore, in the saved document, the string “<br />” looks like “<br />”. In order to get the desired result, you can use the following two methods:
Create BR elements using the CreateElement method and add them to the tree.
using (var htmldocument = new Aspose.Html.HTMLDocument())
{
// Create text and BR elements to add to the HTML document
var machineState = htmldocument.CreateTextNode("Machine state : ");
var br1 = htmldocument.CreateElement("br");
var machineStateValue = htmldocument.CreateTextNode(" d.ContatoreTot2");
var currentSpeedActualFrequence = htmldocument.CreateTextNode("Machine actual frequency : ");
var br2 = htmldocument.CreateElement("br");
var currentSpeedActualVelocity = htmldocument.CreateTextNode("Machine actual velocity : ");
var br3 = htmldocument.CreateElement("br");
var cycleCounter = htmldocument.CreateTextNode("Cycle counter : ");
// Add elements to HTML body
htmldocument.Body.AppendChild(machineState);
htmldocument.Body.AppendChild(br1);
htmldocument.Body.AppendChild(machineStateValue);
htmldocument.Body.AppendChild(currentSpeedActualFrequence);
htmldocument.Body.AppendChild(br2);
htmldocument.Body.AppendChild(currentSpeedActualVelocity);
htmldocument.Body.AppendChild(br3);
htmldocument.Body.AppendChild(cycleCounter);
// Save the HTML file to a disk
htmldocument.Save("lineBreak.html");
}
Or set the InnerHTML property of the Body element to the desired value. In this case, text and BR elements will be created and added automatically.
using (var htmldocument = new Aspose.Html.HTMLDocument())
{
htmldocument.Body.InnerHTML = "Machine state : <br /> " +
"d.ContatoreTot2" +
"Machine actual frequency : <br /> " +
"Machine actual velocity : <br /> " +
"Cycle counter : ";
// Save the HTML file to a disk
htmldocument.Save("lineBreak.html");
}
The issues you have found earlier (filed as HTMLNET-4382) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh