How is this done?

  • Thread starter Thread starter johnb41
  • Start date Start date
J

johnb41

I am planning on writing an application, where, before the user can do
anything, he/she must open up a file...

.... it would be an XML file, which contains all the data that he/she
needs in order to work w/ the program.

The XML file has a corresponding .XSD (schema).

So there are really 2 files.

Here's the question: I would like the XML and XSD to be a SINGLE file.
So the user would start by going to File > Open, and selecting that
single file. I don't want the user to have to open up an XML and also
an XSD... too complicated, and it's not standard to the way most
programs work.

I also want it to be a single file, so it is easily portable from
computer to computer. (Like an MS word .doc is a single file that can
be opened anywhere MS Word is installed)

How is this done? Should all the data be combined in a single file, and
then when it's opened, it's parsed out: one part parsed out and saved
as an XML file, and the other parsed and saved as an XSD.

Can anyone give suggestions?

Thanks!
John
 
John,

If I did understand you than is the answer for me

Use a dataset. That is extremely handy for what you want to do.

Cor
 
Why not have them open the XML file and then the program opens the XSD file
automatically (assuming they are named the same)
 
A dataset isn't actually a "file" that the user can open, is it? To
get info into a dataset, you have to either get it from a datasource
(database, or xml), or create a dataset from scratch. The user needs
to open data that already exists, so creating it from scratch is not an
option.

If a dataset can be opened as a standalone file, then please show me
how! :)

John
 
Terry,

Thanks for helping! The problem is that there are still 2 files. If
the XML file gets moved to a different computer, then the XSD will
probably get forgotten. To the end-user, it would not be obvious that
there are always 2 files that must be used.

John
 
John,

It is so easy I type it in this message so watch typos

\\\
Dim ds as new dataset
dim dt as new datatable
dt.columns.add("john")
dt.rows.add(dt.newrow)
dt.rows(0)(0) = "Hello John"
ds.tables.add(dt)
ds.writexml("C:\mydataset")
///

(reading is ds.readxml(":\mydatasert")

Is that difficult, I did not think so.

I hope this helps,

Cor
 
My current application actually is very similar to this. But instead
of creating a dataset from scratch, my dataset is created from a
ds.readxml. I then add rows, del rows, edit rows, etc. and then
ds.writexml it back to the same xml file.

Anyway, after seeing your code, I thought it still would not work
because I also need an xml schema (xsd), and that is a separate file.

But after playing around, i realized that when doing ds.writexml, there
is a constructor that actually adds a schema into the xml file. So the
result is a single file.

So as it stands, I think this will work for me, and not much XML
expertise is needed. Phew!

Thanks for your help!

John
 

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

Back
Top