473,320 Members | 1,920 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,320 software developers and data experts.

XmlSchema with dataset. Need help!

Hi,

I have a web service that return a Dataset.
I want to get xml result from GetXml method of DataSet class like this:

<xml... .>
<MyDataSet xmlns="ssss\mySchema.xsd>
<Table1>
<RecordTable1>
<id>1</id>
<nome>fulano</nome>
</RecordTable1>
<RecordTable1>
<id>2</id>
<nome>fulano2</nome>
</RecordTable1>
</Table1>
<Table2>
<recordTable2>
<codigo>1</codigo>
</recordTable2>
<recordTable2>
<codigo>2</codigo>
</recordTable2>
</Table2>
</MyDataset>

But the return is:

<xml... .>
<MyDataSet xmlns="ssss\mySchema.xsd>
<RecordTable1>
<id>1</id>
<name>fulano</name>
</RecordTable1>
<RecordTable1>
<id>2</id>
<name>fulano2</name>
</RecordTable1>
<recordTable2>
<code>1</code>
</recordTable2>
<recordTable2>
<code>2</code>
</recordTable2>
</MyDataset>

Have anybody to help me to create a xml schema that the result is like
first example?

I already tried to create a xml schema with a complextype (MyDataSet)
more two elements (Table1 and table2) but doesn't work.

Source code to test:

[WebMethod]
public XmlDocument HelloWorld()
{
DataSet ds = new DataSet("MyDataSet");

DataTable tb1 = new DataTable("Table1");
tb1.Columns.Add(new DataColumn("id"));
tb1.Columns.Add(new DataColumn("name"));
DataRow row = tb1.NewRow();
row[0] = "1";
row[1] = "a";
tb1.Rows.Add(row);
row = tb1.NewRow();
row[0] = "2";
row[1] = "b";
tb1.Rows.Add(row);
ds.Tables.Add(tb1);

DataTable tb2 = new DataTable("Table2");
tb2.Columns.Add(new DataColumn("code"));
row = tb2.NewRow();
row[0] = "3";
tb2.Rows.Add(row);

row = tb2.NewRow();
row[0] = "4";
tb2.Rows.Add(row);
ds.Tables.Add(tb2);
ds.ReadXmlSchema(System.IO.Path.Combine(AppDomain. CurrentDomain.BaseDirectory,
"MySchema.xsd"));

XmlDocument doc = new XmlDocument();
doc.LoadXml(ds.GetXmlSchema());

return doc;
}

Feb 3 '06 #1
0 989

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

Similar topics

0
by: BODIN | last post by:
I have an XML document, which is actually physically stored in 2 separated files. doc1.xml and doc2.xml I NEED a WAY FOR THIS SIMPLE NEED : XML file splitted into two physical files, and use...
1
by: qdm | last post by:
Below is a snippet that I'm sure is quite familiar to most ... <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" Here, I've given the XMLSchema namespace the prefix 'xsd', and with...
0
by: John | last post by:
Hi, I'm creating a component to generate a schema file much like VS generates for DataSets. I'm using XmlSchema to do the job and I also am using a XmlNamespaceManager to manage namespaces. ...
1
by: ree32 | last post by:
When I try and load an xmldocument with its schema into an dataset. It always returns 0 tables. ds.ReadXml(Server.MapPath("\" & "data\ohsReport.xml", XmlReadMode.ReadSchema) Does anyone know...
1
by: Beanweed | last post by:
I am writing a web service in C#. One method queries a database for xml formatted data and responds to the requester with an XMLDocument (this part works fine). What I want now is another method...
1
by: rancidpunx | last post by:
Hello! I have a couple of questions about using XMLSchemas in C#.net. - I want to store data from 5 database-tables in XML Files. Do i need one schema for every table? - I want to store...
2
by: MyndPhlyp | last post by:
I am attempting to write a DLL to maintain an XML file. It creates its own XSD as an XmlSchema (or even a compiled member of an XmlSchemaSet, if necessary). I don't want to write an XSD to disk....
2
by: Martin Madreza | last post by:
Hi, I have a problem with reading an XmlSchema with Frameowk 2.0 and an own DataType. I found no example (searching two days). What I do is: DataSet dataSet = new DataSet();...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.