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

Dataset with Schema -> XML File

This just seems like the most basic thing, but I can't find a simple
description of this process anywhere and in here, everone is talking about
going the other way :( I had .NET create an XML Schema file (xsd) for a table
in my database. I then create a DataSet that contains 1 row of data from that
same table. I want to use this DataSet along with the Schema file to create
an XML file that ACTUALLY CONTAINS THE DATA. Simple huh: DataSet + Schema ->
Test.xml file WITH DATA. Would someone please show me how that is done?
Nov 19 '05 #1
4 1858

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
This just seems like the most basic thing, but I can't find a simple
description of this process anywhere and in here, everone is talking about
going the other way :( I had .NET create an XML Schema file (xsd) for a table in my database. I then create a DataSet that contains 1 row of data from that same table. I want to use this DataSet along with the Schema file to create an XML file that ACTUALLY CONTAINS THE DATA. Simple huh: DataSet + Schema -> Test.xml file WITH DATA. Would someone please show me how that is done?


This snip takes an existing xml file, changes the data and saves it. Maybe
it will give you some ideas.

Dim doc as XmlDataDocument = new XmlDataDocument()
'Load the schema.
doc.DataSet.ReadXmlSchema(yourschemafile)
'Load the XML data.
doc.Load(yourxmlfilename)
Dim dt as DataTable = doc.DataSet.Tables("yourtablename")
dim dv as dataview = new dataview(dt)
do data manipulation here
doc.Save(yourxmlfilename)
Mike
Nov 19 '05 #2
Thanx vMike, but I don't think I'm being clear. In your code, you wrote

'Load the XML data.
doc.Load(yourxmlfilename)

which suggests to me that the "yourxmlfilename" file is ALREADY populated
with data and if so, that isn't what I mean. Effectively that is taking a
"populated" XML file, loading it into a DataSet, modifying it and the writing
it back to the XML File.

I am talking about STARTING with JUST the XML schema, without ANY data.
Creating a DataSet (NOT FROM AN XML FILE) right from the database that
matches the requirement of this schema and POPULATING an EMPTY XML File with
the data from the DataSet in the XML formate specified by the Schema.

Do you understand? A DATALESS Schema + a DataSet (NOT FROM AN XML FILE BUT)
from the database itself and outputing an XML FILE that is populated with the
data from the DataSet and in the format of the Schema.

"vMike" wrote:

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
This just seems like the most basic thing, but I can't find a simple
description of this process anywhere and in here, everone is talking about
going the other way :( I had .NET create an XML Schema file (xsd) for a

table
in my database. I then create a DataSet that contains 1 row of data from

that
same table. I want to use this DataSet along with the Schema file to

create
an XML file that ACTUALLY CONTAINS THE DATA. Simple huh: DataSet +

Schema ->
Test.xml file WITH DATA. Would someone please show me how that is done?


This snip takes an existing xml file, changes the data and saves it. Maybe
it will give you some ideas.

Dim doc as XmlDataDocument = new XmlDataDocument()
'Load the schema.
doc.DataSet.ReadXmlSchema(yourschemafile)
'Load the XML data.
doc.Load(yourxmlfilename)
Dim dt as DataTable = doc.DataSet.Tables("yourtablename")
dim dv as dataview = new dataview(dt)
do data manipulation here
doc.Save(yourxmlfilename)
Mike

Nov 19 '05 #3

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Thanx vMike, but I don't think I'm being clear. In your code, you wrote

'Load the XML data.
doc.Load(yourxmlfilename)

which suggests to me that the "yourxmlfilename" file is ALREADY populated
with data and if so, that isn't what I mean. Effectively that is taking a
"populated" XML file, loading it into a DataSet, modifying it and the writing it back to the XML File.

I am talking about STARTING with JUST the XML schema, without ANY data.
Creating a DataSet (NOT FROM AN XML FILE) right from the database that
matches the requirement of this schema and POPULATING an EMPTY XML File with the data from the DataSet in the XML formate specified by the Schema.

Do you understand? A DATALESS Schema + a DataSet (NOT FROM AN XML FILE BUT) from the database itself and outputing an XML FILE that is populated with the data from the DataSet and in the format of the Schema.

"vMike" wrote:

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
This just seems like the most basic thing, but I can't find a simple
description of this process anywhere and in here, everone is talking about going the other way :( I had .NET create an XML Schema file (xsd) for
a table
in my database. I then create a DataSet that contains 1 row of data
from that
same table. I want to use this DataSet along with the Schema file to

create
an XML file that ACTUALLY CONTAINS THE DATA. Simple huh: DataSet +

Schema ->
Test.xml file WITH DATA. Would someone please show me how that is
done?
This snip takes an existing xml file, changes the data and saves it. Maybe it will give you some ideas.

Dim doc as XmlDataDocument = new XmlDataDocument()
'Load the schema.
doc.DataSet.ReadXmlSchema(yourschemafile)
'Load the XML data.
doc.Load(yourxmlfilename)
Dim dt as DataTable = doc.DataSet.Tables("yourtablename")
dim dv as dataview = new dataview(dt)
do data manipulation here
doc.Save(yourxmlfilename)
Mike

Have you looked into the dataset.writexml method.

Mike

Nov 19 '05 #4
Ok I got it Mike...I'm a dickhead. I was doing it correctly, cocksure that my
dataset had data and it didn't. Thanx ;)

"vMike" wrote:

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Thanx vMike, but I don't think I'm being clear. In your code, you wrote

'Load the XML data.
doc.Load(yourxmlfilename)

which suggests to me that the "yourxmlfilename" file is ALREADY populated
with data and if so, that isn't what I mean. Effectively that is taking a
"populated" XML file, loading it into a DataSet, modifying it and the

writing
it back to the XML File.

I am talking about STARTING with JUST the XML schema, without ANY data.
Creating a DataSet (NOT FROM AN XML FILE) right from the database that
matches the requirement of this schema and POPULATING an EMPTY XML File

with
the data from the DataSet in the XML formate specified by the Schema.

Do you understand? A DATALESS Schema + a DataSet (NOT FROM AN XML FILE

BUT)
from the database itself and outputing an XML FILE that is populated with

the
data from the DataSet and in the format of the Schema.

"vMike" wrote:

"Sindarian" <Si*******@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
> This just seems like the most basic thing, but I can't find a simple
> description of this process anywhere and in here, everone is talking about > going the other way :( I had .NET create an XML Schema file (xsd) for a table
> in my database. I then create a DataSet that contains 1 row of data from that
> same table. I want to use this DataSet along with the Schema file to
create
> an XML file that ACTUALLY CONTAINS THE DATA. Simple huh: DataSet +
Schema ->
> Test.xml file WITH DATA. Would someone please show me how that is done?
This snip takes an existing xml file, changes the data and saves it. Maybe it will give you some ideas.

Dim doc as XmlDataDocument = new XmlDataDocument()
'Load the schema.
doc.DataSet.ReadXmlSchema(yourschemafile)
'Load the XML data.
doc.Load(yourxmlfilename)
Dim dt as DataTable = doc.DataSet.Tables("yourtablename")
dim dv as dataview = new dataview(dt)
do data manipulation here
doc.Save(yourxmlfilename)
Mike

Have you looked into the dataset.writexml method.

Mike


Nov 19 '05 #5

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

Similar topics

1
by: harry | last post by:
Hello, not certain if this should go here or ado.net but I'm trying to create an XSD on the fly (due to the fact that our dataaccess component is a legacy component which returns data in an...
0
by: Patrick Kearney | last post by:
Hi All, I have seen this type of question raised in various groups but no one has supplied a definitive answer. I am trying to load a dataset schema that has an xs:include. Project policy is to...
1
by: David Laub | last post by:
The following valid XSD schema can NOT be successfully read by the ReadXMLSchema method of the DataSet object - it errors out with a "NonEmptyString not defined" error. This schema is more complex...
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...
22
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...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
13
by: Maxwell2006 | last post by:
Hi, We are having a debate over using DataSet as return value type for web services. The problem is that we don't know whether Java applications can use DataSet
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
0
by: rickbear | last post by:
Hi group... I am having big difficulties with dataset and xsd schemas. First I dedicate a specific schema to a dataset. Then I use an adapter to fill each table in the dataset. But the problem...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
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...

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.