DataSet & Xml

J

Josh

Hi,

Is it possible for a DataSet to read and write CDATA section to/from xml?
Is there a way to cause all text fields being exported from an sqlce db
table to be in CDATA sections?

thanks
Josh
 
I

Ilya Tumanov [MS]

Yes, DataSet can read CDATA sections from XML. Content of CDATA will be
treated as text.
For example, this XML can be loaded:

<DS>
<xs:schema id="DS" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="DS"
msdata:IsDataSet="true"><xs:complexType><xs:choice minOccurs="0"
maxOccurs="unbounded"><xs:element
name="Table"><xs:complexType><xs:sequence><xs:element name="Column"
type="xs:string" minOccurs="0"
/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><
/xs:element></xs:schema>
<Table>
<Column><![CDATA[CDATASECTIONGOESHERE]]></Column>
</Table>
</DS>

No, DataSet can not write CDATA sections to XML. This is how it would look
if you load XML above into the DataSet and save it:

<DS><xs:schema id="DS" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="DS"
msdata:IsDataSet="true"><xs:complexType><xs:choice minOccurs="0"
maxOccurs="unbounded"><xs:element
name="Table"><xs:complexType><xs:sequence><xs:element name="Column"
type="xs:string" minOccurs="0"
/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><
/xs:element></xs:schema>
<Table>
<Column>CDATASECTIONGOESHERE</Column>
</Table>
</DS>

There's no standard API to export SQL CE DB into the XML.
You can use SqlCeDataReader to read data from SQL CE and save it manually
in any format you need (XML with CDATA, binary, CSV, etc.).

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top