Re: How to insert a CDATA section using XPathNavigator ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Eric,

Can you describe how you determined if it worked or not? Are you listing an
output file or maybe you just look for the expected data through
XPathNavigator. As I explained before, in the context of XPathNavigator a
CDATA section will surface as Text plus the markup (ie. "<![CDATA[", "]]>")
will be missing from the observable value.

Ion

"ericms" <ericms@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D9FCC5BF-C57C-4AA2-92B1-F5DC245E6F84@xxxxxxxxxxxxxxxx
I have tried it and the following did not work:
writer.WriteCData(dataString);
It did not add the <![CDATA]]> demiliters as you indicated.

I am using VisualStudio 2005, .NET 2.0.


Thanks,
Eric.-



"Martin Honnen" wrote:



ericms wrote:


And when I did the following :

using (XmlWriter writer = nav.AppendChild())
{
writer.WriteCData("<![CDATA[" + dataString + "]]>");
}

Everything is fine except that the "less than" sign is replaced with
ampersand, lt, semicolon and the greater sign is replaced with
ampersand, gt,
semicolon.

Simply do
writer.WriteCData(dataString);
do _not_ write out the <![CDATA]]> demiliters yourself, the writer will
add them directly when WriteCData is executed.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/



.



Relevant Pages