DataSet to XML

J

Joe98765

I have data coming from SQL Server and need to write out some XML. I
have a schema(xsd) for this XML file. Right now I am bringing in the
DataSet and writing out the elements and attributes myself using
xmltextwriter to match schema without really using the xsd at the time
of writing.

The file I create validates but I was wondering is there a better way?
I see things like inferschema method off of dataset, can this be used?
How do you map columns in a dataset with elements and attributes in
the schema? I know dataset.WriteXmL will write XML but that match my
schema. Appreciate any help!

Thanks,
Joe
 
L

Lars Wilhelmsen

Hi Joe,

Joe98765 said:
I have data coming from SQL Server and need to write out some XML. I
have a schema(xsd) for this XML file. Right now I am bringing in the
DataSet and writing out the elements and attributes myself using
xmltextwriter to match schema without really using the xsd at the time
of writing.

The file I create validates but I was wondering is there a better way?
I see things like inferschema method off of dataset, can this be used?
How do you map columns in a dataset with elements and attributes in
the schema? I know dataset.WriteXmL will write XML but that match my
schema. Appreciate any help!

I find it a bit hard to grasp your problem - you want to write out the
DataSet as
xml - and you want it to validate against your schema - but you don't want
to
use the dataset.WriteXml() that actually writes out conforming xml !?

Is it speed/other performance issues you're troubling with?
 
J

Joe98765

Lars Wilhelmsen said:
Hi Joe,



I find it a bit hard to grasp your problem - you want to write out the
DataSet as
xml - and you want it to validate against your schema - but you don't want
to
use the dataset.WriteXml() that actually writes out conforming xml !?

Is it speed/other performance issues you're troubling with?


Sorry, let me clarify...as I mistyped "I know dataset.WriteXML will
write XML but that DOESN'T match my schema".

dataset.writexml would be great...but how do you get it to write xml
based on a existing schema? Is there a way to associate an existing
schema and map my columns in the dataset to elements/attributes and
then call the WriteXml method?
 
M

Mark Bosley

Sorry, let me clarify...as I mistyped "I know dataset.WriteXML will
write XML but that DOESN'T match my schema".

dataset.writexml would be great...but how do you get it to write xml
based on a existing schema? Is there a way to associate an existing
schema and map my columns in the dataset to elements/attributes and
then call the WriteXml method?

I think you are not framing your question quite right. Validation based on a
schema happens during the reading, not writing.

A truely wonderful free reference is the sample chapter from Bob
Beauchemin's
Essential ADO.Net

http://www.awprofessional.com/bookstore/product.asp?isbn=0201758660
 

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