471,089 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 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 1751

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Patrick Kearney | last post: by
22 posts views Thread by Arne | last post: by
13 posts views Thread by Maxwell2006 | last post: by
1 post views Thread by Angel \Java\ Lopez | last post: by
reply views Thread by rickbear | last post: by
reply views Thread by =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post: by

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.