As
Dave Kreskoviak[
^] mentioned (solution 1), you have to include HTML content into CDATA section.
string HtmlText = @"<p><font face="Times New Roman" size="3">
</font></p><p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="DA" style="line-height: 115%; font-family: " tahoma="," sans-serif="; font-size: 8.5pt;">Hello Dummy text need XML n 18. juni 2015.</span><span lang="DA" style="line-height: 115%; font-family: " tahoma="," sans-serif="; font-size: 8.5pt;"><br>
<br>
demo text for experiment være
opmærksom på følgende regler:<br>
<br>
1. Fl hello texten<br>
<br>
Street 101 Indiae adresse.<br>
<br>";
XDocument xdoc = new XDocument();
XElement xroot = new XElement("MyXml");
XElement xdata = new XElement("MyData", new XCData(HtmlText));
xroot.Add(xdata);
xdoc.Add(xroot);
Result:
<MyXml>
<MyData><![CDATA[</MyData>
</MyXml>
Otherwise, you'll be forced to replace each
<
and
>
into:
< and >