473,670 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet to XML

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.WriteXm L will write XML but that match my
schema. Appreciate any help!

Thanks,
Joe
Nov 12 '05 #1
3 10284
Hi Joe,

"Joe98765" <jo***********@ hotmail.com> wrote in message
news:44******** *************** ***@posting.goo gle.com...
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.WriteXm L 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.WriteXm l() that actually writes out conforming xml !?

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

--
Lars Wilhelmsen
http://www.sral.org/
Software Engineer
Teleplan A/S, Norway
Nov 12 '05 #2
"Lars Wilhelmsen" <la*****@NOSPAM .ifi.uio.no> wrote in message news:<uf******* *******@tk2msft ngp13.phx.gbl>. ..
Hi Joe,

"Joe98765" <jo***********@ hotmail.com> wrote in message
news:44******** *************** ***@posting.goo gle.com...
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.WriteXm L 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.WriteXm l() 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.WriteXM L will
write XML but that DOESN'T match my schema".

dataset.writexm l 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?
Nov 12 '05 #3
>
Sorry, let me clarify...as I mistyped "I know dataset.WriteXM L will
write XML but that DOESN'T match my schema".

dataset.writexm l 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/bookst...sbn=0201758660
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4594
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. I'm getting some strange results depending the input XML file I use. I was wondering if somebody could help me understand what is going on or point me to a good reference. The code for my program looks like this:
3
6597
by: Jeronimo Bertran | last post by:
Hi, I have an xml file that encapsulates a dataset definition within a set of tags (<dataset>)... here is an example <?xml version="1.0" encoding="utf-16"?> <dataset> <MyTable> <Field1>100</Field1> <Field2>200</Field2>
5
5398
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an actual DataSet? e.g. public class MyDataSet : DataSet { // can't do, no valid DataSet constructor
3
13584
by: JJ | last post by:
Hi, I need to pass a dataset to another win form along with a SqldataAdapter. I don't want to recreate the SqlDataAdapter again either. So to pass to another Win form in my windows form app, do I create the procedure to pass by ref? Which means I don't need to add ByRef because it is defaulted by ref, correct? And in the constructor of the win form that gets created. I need to add in parameters a DataSet and SqlDataAdapter correct? What...
5
3695
by: Jason | last post by:
I am having problems understanding how to access a datasource only once, fill a single dataset, and then reference that dataset multiple times through different user controls(ascx) found on the same page. My main page(aspx) contains multiple user controls. The main page also contains a publicly declared dataset. At the first instance of needing data I call (from an ascx) a function that fills the dataset and then returns it to the...
2
3380
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and then appends the data to a dataset that is built in the Page_Load code in the if(!isPostBack) block. When I try to add a row in the button click event code I get an error saying that "Object reference not set to an instance of an object". I'm...
15
2242
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
16
2475
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill it with incremental values e.g. if the tables looks like this: 23 56
22
25575
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
1
2527
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then can re-run the report and get fresh data. now, they would like to be able to compare the fresh data to the stored data, getting a break-down of added/deleted/changed rows. on the surface, this sounded plausible -- by deserializing the stored
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.