Link to home
Start Free TrialLog in
Avatar of rcoast
rcoast

asked on

Using DTD to open XML document with correct schema (C#, ADO.NET)

I need an example of an XML and DTD, so I can learn how to open a DataSet object, while preserving the data types, sizes, and other schema from the data. I am using C#.
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

May be I do not understand somehing but if you are going to use xml schema (xsd files) you don't need dtd.
If you have xml and schema - that's all you need to load proper types to a dataset etc.

See for example http://www.developer.com/db/article.php/3069061
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcoast
rcoast

ASKER

Thanks for this... but I'm not sure if this is what I need.

I'm going to get an XML file from an external source, with a schema (I wrote DTD, but I assume XSD is the best way to do this).

I want to load the XML, using the XSD (or DTD) into a dataset that is strongly typed, at runtime, not design time.

The goal is that I want my dataset to know which fields are integers, which are floats, which are allowed nulls, etc...

But, my problem is, I will not have the luxury of running a command line tool to generate C# (or VB) code at runtime.
Avatar of rcoast

ASKER

This is the one. Thanks!
Xsd file (schema) will tell the dataset all datatypes etc. That is what schema for.
So, at run time you create a dataset, read schema - now dataset knows about types etc.
Than you load data from xml.

In this scenario the hardest part is to create xsd. If you are not proficient - this might be a tricky task.
What I do sometimes: I create a dataset, create tables for dataset, define types for columns etc. All from code. Then I call dataset.WriteXmlSchema - and I have a schema file I can reuse for my application.