Hello Bill,
Based on your description, your main concern here is looking for a best
means to replace all the CData Sections in your report XML document with
normal text node(with some encoding), correct?
I've tried some xpath or XSLT approach, but seems doesn't quite suit the
scenario here. One means I've got is creating a custom XmlWriter and
override the "WriteCData" method so as to do our own customized output code
logic for CData node in XML Document. here is a very simple custom writer
class demonstrate this:
===============================
public class ReplaceXMLWriter: XmlTextWriter
{
public ReplaceXMLWriter(string filename, Encoding encoding)
: base(filename, encoding)
{
}
public override void WriteCData(string text)
{
string oldText = text;
Console.WriteLine("ReplaceXMLWriter+WriteCData+old Text:{0}",
oldText);
base.WriteString(HttpUtility.HtmlEncode( text));
}
}
==================================
You can simply use your custom writer class as below:
====================
static void Run()
{
XmlDocument doc = new XmlDocument();
doc.Load(@"..\..\data.xml");
ReplaceXMLWriter rxw = new ReplaceXMLWriter("replaceddata.xml",
Encoding.UTF8);
doc.Save(rxw);
rxw.Close();
}
=========================================
Does this helps you?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.