Map DataSet Elements to CDATA Sections
Does your data contain reserved XML characters? Preserve it "as is" when pulling it from the database.
by Dan Wahlin
Posted April 21, 2003
In version 1.0 of .NET, DataSets do not provide an internal MappingType that allows element data to be wrapped with a CDATA section when XML is generated. This can present a problem when data pulled from the database contains reserved XML characters such as < because the DataSet GetXml() and WriteXml() methods escape these characters (< becomes <). This demo shows how you can map DataSet elements to CDATA sections using a custom class named CDATAGenerator. Doing so helps preserve data "as is" rather than convert some of it into entities.
Download the example here, originally from the XML for ASP.NET Developers site.
About the Author
Dan Wahlin authored XML for ASP.NET Developers (Sams) and founded Wahlin Consulting, which focuses on XML and Web Service consulting and training. Dan also operates the XML for ASP.NET Developers Web site: www.XMLforASP.NET. Find more information at http://www.xmlforasp.net/Dan.aspx.
Back to top
|