output data into another systems XML schema

elvisisdog

New member
Joined
Sep 12, 2006
Messages
1
Programming Experience
5-10
Hi,

I'm trying to output data from SQL Server 2005 in VB.net 2003 using ADO.net. I have to ensure the format of the XML file is the same as the provider that we subscribe to which naturally doesn't match the schema of our database. I've been trying to use an XML schema that I've created for the output file with a dataset that I've read from my database. The problem is when I call ds.writeXML() I get the data in the format from my database. I know that I need to map the data from my dataset to the dataset of the xml schema although I'm having difficulty in finding an example that explains how I reference the XML schema dataset table names and fields.

Has anyone got a small example where they extract from a database into a dataset then map into the dataset from an XML schema preferably which has nested elements?

I know its a tall ask but I'm fighting trying to get my head around the Microsoft help files as I find individual bits but nothing linking it all together. Any pointers in the right direction would be great.

Thanks
Neil
 
You could use the Dataset.WriteXmlSchema method to see how the system presents your current dataset as Xml schema, modify it to the output format, then use the Dataset.InferXmlSchema method to apply the new schema to the current dataset, before you finally use Dataset.WriteXml to export the new Xml. I haven't actually done a test of this, but it sounds logical to me :)
Here's the XML Schemas (XSD) Reference at MSDN, here's a Xml Schema tutorial at W3Schools.
 
Another idea is to do a Xsl transformation of the regular Xml output, this Xsl you set up to do the conversion of Xml structure. Examples from Wiki
 
Back
Top