
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
852
|
Chapter 15: XML
When the CDATA tag is used in conjunction with the InnerXml property of the
XmlElement class, you can submit characters that would normally need to be escaped
first. The
XmlElement class also has an InnerText property that will automatically
escape any markup found in the string assigned. This allows you to add these charac-
ters without having to worry about them.
See Also
See the “XmlDocument Class,” “XmlWriter Class,” “XmlElement Class,” and
“CDATA Sections” topics in the MSDN documentation.
15.8 Transforming XML
Problem
You have a raw XML document that you need to convert into a more readable for-
mat. For example, you have personnel data that is stored as an XML document and
you need to display it on a web page or place it in a comma-delimited text file for leg-
acy system integration. Unfortunately, not everyone wants to sort through reams of
XML all day; they would rather read the data as a formatted list or within a grid with
defined columns and rows. You need a method of transposing the XML data into a
more readable form as well as into the comma-delimited format.
Solution
The solution for this is to use an XSLT stylesheet to transform the XML into another
format using the
XslCompiledTransform class. In the example code, you transform
some personnel data from a ...