Dataset with Schema -> XML File

G

Guest

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?
 
V

vMike

Sindarian said:
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
 
G

Guest

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.
 
V

vMike

Sindarian said:
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.
Have you looked into the dataset.writexml method.

Mike
 
G

Guest

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 ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top