CDATA Mapping Experience inside BizTalk

Posted: July 1, 2007  |  Categories: BizTalk 2006 Uncategorized
You can download the entire article as a PDF document.
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.


You can download the entire article as a PDF document.
CDATA Mapping Experience Inside BizTalk
#1 all-in-one platform for Microsoft BizTalk Server management and monitoring
Author: Steef-Jan Wiggers

Steef-Jan Wiggers is all in on Microsoft Azure, Integration, and Data Science. He has over 15 years’ experience in a wide variety of scenarios such as custom .NET solution development, overseeing large enterprise integrations, building web services, managing projects, designing web services, experimenting with data, SQL Server database administration, and consulting. Steef-Jan loves challenges in the Microsoft playing field combining it with his domain knowledge in energy, utility, banking, insurance, healthcare, agriculture, (local) government, bio-sciences, retail, travel, and logistics. He is very active in the community as a blogger, TechNet Wiki author, book author, and global public speaker. For these efforts, Microsoft has recognized him a Microsoft MVP for the past 8 years.


Back to Top