After creating an xml file using XDocument I end up with:
<![CDATA[text]]>
and
<br />
But I want to keep these as HTML, how do I stop this?
After creating an xml file using XDocument I end up with:
<![CDATA[text]]>
and
<br />
But I want to keep these as HTML, how do I stop this?
I assume you are passing a string to an XDocument or XElement constructor somewhere, where that string contains XML. Don't. Instead, use
XDocument.Parse(string)
orXElement.Parse(string)
.See http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.parse.aspx and http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.parse.aspx
Note that this will only work for HTML that happens to be well-formed XML, obviously.
For example:
If you statically know the text, just build it up using constructor calls, e.g.