473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Loosing schema information while converting DataSet to XML

Hello,

I have a Client/Server system based on a single generic communication method
using XML (as done in MS Project-Server or SharePoint-WebServices).

To transfer DataSets I'am using XmlDataDocument.
This works fine.
However the created XmlDataDocument does not contain schema information,
i.e. the datatypes of the columns in the dataset-tables are lost.

Is there any way to include the shema info?

(I cannot use dataSet.WriteXml because I don't need a file or stream, I need
a XmlDocument!)

Thank you
Wolfgang
Code fragment:
// Create dataset or get it from database
DataSet dataSet = GetDataSet();

// Test: Write to file, including schema information
dataSet.WriteXml("C:\\test1.xml", XmlWriteMode.WriteSchema);

// Create XML document from dataset, does obviously NOT include schema
information!
XmlDataDocument xDoc = new XmlDataDocument(dataSet);

// Normally the XmlDocument will be returned here
// return xDoc;

// Test: Write to file: has NO schema information
xDoc.Save("C:\\test2.xml");
Nov 12 '05 #1
3 1716
Hi Wolfgang,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to load the schema information
into a XmlDataDocument and pass it through an xml web service. If there is
any misunderstanding, please feel free to let me know.

As far as I know, the XmlDataDocument doesn't load the schema information
by default. Since you don't want to write to any file, we can write it to a
string using a StringWriter. Here is an example:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
this.dataSet12.WriteXml(new System.IO.StringWriter(sb),
XmlWriteMode.WriteSchema);
XmlDataDocument doc = new XmlDataDocument();
doc.LoadXml(sb.ToString());
doc.Save(@"c:\emp1.xml");

HTH.

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

Nov 12 '05 #2
Hi Kevin,

thank you very much.
You get the solution!
Now everything works like expected.

Wolfgang
Nov 12 '05 #3
You're welcome.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

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

Nov 12 '05 #4

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

Similar topics

1
by: Scott M. | last post by:
I have created a strongly typed dataset and populated it with data in my data layer. I have confirmed that the DataSet does, in fact contain my data and that there is a schema governing this data...
10
by: Al Christoph | last post by:
Please forgive me if this is the wrong place to post this. The last place I posted got me a fairly rude response. I guess vb.db people just don't want to think about XML as database. At any rate,...
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
2
by: ertanasan1 | last post by:
Hi, //Returns a new dataset with tree datatables. dsTemp.ReadXmlSchema(@"C:\mysch.xsd"); //Add a row to data table 0 DataRow dr = dsTemp.Tables.NewRow(); dr = "value1";...
12
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
9
by: PeterWellington | last post by:
I have a column in a data table that stores enum values and assigns a default value: Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday When I...
2
by: MaLec | last post by:
I’d like to use the DataSet as the container for the XML files conforming to some schema. The problem is, that the operation of reading the XML file into the DataSet having its schema and then...
13
by: Martin Z | last post by:
I'm making a CRUD screen for an Oracle database... but problem is that the primary key in that table is populated via an autonumber, which in Oracle is done just with triggers and sequences. ...
4
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
how can persist schema for a sql server table into an xml file from .net application? thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.