Microsoft KB Archive/317706

= BUG: The data set does not contain CDATA sections after you load an XML document =

Article ID: 317706

Article Last Modified on 9/15/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft .NET Framework 1.0

-



This article was previously published under Q317706



SYMPTOMS
The CDATA sections in an XML document are not inserted correctly in the data table when you use the ReadXml method of the DataSet object to read the XML file.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
  In Notepad, create a new XML document that contains the following XML data:     <![CDATA[BARRYS]]>   <![CDATA[ANTONY]]>   <![CDATA[ROPKA]]>   <LEVEL1 name=&quot;20&quot;>  <![CDATA[MCCOMAS]]> </LEVEL2>  <![CDATA[ABINGIN]]> </LEVEL2>  <![CDATA[CHELSEA]]> </LEVEL2> </LEVEL1> </ROOT> </li> <li>Save the document as Test.xml in the root folder of your hard disk.</li> <li>In Visual Studio .NET, create a new Microsoft Visual C# .NET Windows Application project.</li> <li>Drag two Button controls from the toolbox to Form1.</li> <li> Create a public member in public class Form1 to create a new data set: public DataSet ds = new DataSet; </li> <li> Paste the following code in the Click event procedure of Button1: try {               ds.ReadXml(&quot;c:\\test.xml&quot;); MessageBox.Show(&quot;Done!&quot;); }   catch (Exception exc) {       MessageBox.Show(exc.Message); }                       </li> <li> Paste the following code in the Click event procedure of Button2: try {       ds.WriteXml(&quot;c:\\test_new.xml&quot;); MessageBox.Show(&quot;New File Written!&quot;); }   catch (Exception exc) {       MessageBox.Show(exc.Message); }

</li> <li>Save the changes to the Visual C# .NET project, and then run the application.</li> <li>Click Button1 to fill the data set with the data from the XML file that you created.</li> <li>Click Button2 to write out a new XML file (Test_new.xml) from the data set.</li> <li> Open the new file (Test_new.xml) and note that the XML data is missing the CDATA sections: <?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?> <ROOT> <LEVEL1 name=&quot;10&quot;>    </LEVEL1> <LEVEL1 name=&quot;20&quot;>    </LEVEL1> </ROOT> </li></ol>

Keywords: kbbug kbpending kbvs2002sp1sweep KB317706

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.