473,977 Members | 51,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\myS chema.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\myS chema.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("MyData Set");

DataTable tb1 = new DataTable("Tabl e1");
tb1.Columns.Add (new DataColumn("id" ));
tb1.Columns.Add (new DataColumn("nam e"));
DataRow row = tb1.NewRow();
row[0] = "1";
row[1] = "a";
tb1.Rows.Add(ro w);
row = tb1.NewRow();
row[0] = "2";
row[1] = "b";
tb1.Rows.Add(ro w);
ds.Tables.Add(t b1);

DataTable tb2 = new DataTable("Tabl e2");
tb2.Columns.Add (new DataColumn("cod e"));
row = tb2.NewRow();
row[0] = "3";
tb2.Rows.Add(ro w);

row = tb2.NewRow();
row[0] = "4";
tb2.Rows.Add(ro w);
ds.Tables.Add(t b2);
ds.ReadXmlSchem a(System.IO.Pat h.Combine(AppDo main.CurrentDom ain.BaseDirecto ry,
"MySchema.xsd") );

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

return doc;
}

Feb 3 '06 #1
0 1019

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

Similar topics

0
1789
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 of XML Schema.
1
1405
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 that, I can reference datatypes within the XMLSchema namespace ... i.e., xsd:string. That's great, but why can't I use that same notation, to reference dataypes in a homegrown schema ... WITHOUT doing an <import> or
0
1358
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. XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); nsmgr.AddNamespace("msdata", "urn:schemas-microsoft-com:xml-msdata"); nsmgr.AddNamespace("mstns",...
1
1168
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 what is causing this problem? ----------- OhsReport.xml -------------- <?xml version="1.0" standalone="yes"?>
1
1428
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 that will return the schema for that document. My idea is to create a DataSet using the xml document and inferring its schema (the data sources for these xml docs are varied). Then the schema could be extracted from the dataset and sent to the...
1
1203
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 every table in an explicit XML-File! Can i also do this using just one schema AND...
2
1537
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. The XML file, on the other hand, will be disk resident. System.Data.DataSet wants to read its schema in from an XmlReader, Stream, TextReader, or file name string.
2
3704
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(); dataSet.ReadXml("{path}/MySchemaAndData.xml");
0
2046
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 for further use. To create the schema I am using the XMLSchema classes and the result is the
0
10356
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
10172
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
10914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10085
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
8464
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
6418
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
6561
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5159
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
4732
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.