Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding HTML to a XML element 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
Hi,

Everytime I add HTML to a XML element it converts the code to a &lt;html&gt; etc. I am adding a CDATA section so i am not sure why its converting the < symbols. Does anyone know how I can prevent it character escaping like this?

Thanks

Matt
 
Whats your code look like?

Jon

"I don't regret this, but I both rue and lament it.
 
Code:
XmlCDataSection CData;

CData = doc.CreateCDataSection(xmltext.Value);

XmlNode messageNode = doc.CreateNode(XmlNodeType.Element, "Message", "");

messageNode.AppendChild(CData);

Matt
 
Using this code:
Code:
XmlDocument doc = new XmlDocument();
XmlCDataSection CData;
CData = doc.CreateCDataSection("<html><body><p>test</p></body></html>");
XmlNode messageNode = doc.CreateNode(XmlNodeType.Element, "Message", "");
messageNode.AppendChild(CData);
Response.Write(messageNode.InnerXml);
Gives me:

<![CDATA[<html><body><p>test</p></body></html>]]>

They must be getting converted elsewhere.

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top