CDATA Mapping Experience inside BizTalk

XML CDATA is something I was not really familiar with before. Xml parsers normally parse all text in an xml document. Text inside a CDATA section is ignored. This week I stumbled over CDATA sections inside a message. This message I had to map to another message with a different structure and later on had to be passed to a web service. During mapping I seem to have lost the CDATA Section. I googled around, but I could not find a satisfactory solution to my problem. So I started experimenting with inline xslt and c# inside a script functoid. Unfortunately I had no result. I got CDATA section around data, but <> translated into ;lt and ;gt when I opened the resulting message inside notepad (when I temporarily saved it to file). In the end I got fed up with it and called a function inside a class module. I created a component (class library) with the class module and passed the mapped message as xml document to function I created. The function is listed below:

public XmlDocument AddCDataSection(XmlDocument xmlDoc)
XmlNodeList xmlNodeList = xmlDoc.DocumentElement.SelectNodes(xpathquery);

foreach (XmlNode node in xmlNodeList)
string x = node.InnerText;
string lang = String.Empty;
if (node.Attributes["lang"] != null)

lang = node.Attributes["lang"].InnerText;


node.InnerText = string.Empty;
XmlAttribute att = xmlDoc.CreateAttribute("lang");
att.Value = lang;



return xmlDoc;

The returned document I copied back into a new message inside a message assign shape. This gave me the desired result. Maybe there is a better way of mapping inside BizTalk with CDATA Sections. If anybody knows a better solution to CDATA Section and mapping I am happy to hear about it.