Have you ever struggled to generate a Strongly Typed Dataset from an xml File.
Most of you guys might be knowing this technique.
This post is for my friends who dont know how to implement that.I shall explain that to you with the help of two batch files.
One for converting and xml file to its corresponding schema file,ie;xsd and next to generate its class file.
Before that..just a slight introduction.
There are generally two types of dataset.
1.Untyped Dataset
2.Typed Dataset
In an untyped dataset we access a table as,
dataSet.Tables[0]
But in a Typed Dataset it can be accessed by giving,
dataSet.TableName
ie; direct access.
There are many other features.This was just to give a slight idea.
Now we shall see the batch file to convert xml file into xsd.
Type the following code in notepad
c:
cd %VS2003DIR%\SDK\v1.1\Bin
xsd C:\xmlConverter\abc.xml /out:K:\dotnet\csharp\dialogs
pause
and save this file as xmlToSchema.bat
Now run this batch file.
A new file called abc.xsd will be now available in K:\dotnet\csharp\dialogs
Now create the next batch file.
c:
cd %VS2003DIR%\SDK\v1.1\Bin
xsd K:\dotnet\csharp\dialogs\abc.xsd /c /out:K:\dotnet\csharp\dialogs
pause
Save this file as schemaToCS.bat
On running this file the corresponding class file for the xsd will be generated.Now if we read the xml file to a dataset, the dataset will be a typed dataset.
Very simple right? Hope this is of use to somebody or the other.
Cheers...
Most of you guys might be knowing this technique.
This post is for my friends who dont know how to implement that.I shall explain that to you with the help of two batch files.
One for converting and xml file to its corresponding schema file,ie;xsd and next to generate its class file.
Before that..just a slight introduction.
There are generally two types of dataset.
1.Untyped Dataset
2.Typed Dataset
In an untyped dataset we access a table as,
dataSet.Tables[0]
But in a Typed Dataset it can be accessed by giving,
dataSet.TableName
ie; direct access.
There are many other features.This was just to give a slight idea.
Now we shall see the batch file to convert xml file into xsd.
Type the following code in notepad
c:
cd %VS2003DIR%\SDK\v1.1\Bin
xsd C:\xmlConverter\abc.xml /out:K:\dotnet\csharp\dialogs
pause
and save this file as xmlToSchema.bat
Now run this batch file.
A new file called abc.xsd will be now available in K:\dotnet\csharp\dialogs
Now create the next batch file.
c:
cd %VS2003DIR%\SDK\v1.1\Bin
xsd K:\dotnet\csharp\dialogs\abc.xsd /c /out:K:\dotnet\csharp\dialogs
pause
Save this file as schemaToCS.bat
On running this file the corresponding class file for the xsd will be generated.Now if we read the xml file to a dataset, the dataset will be a typed dataset.
Very simple right? Hope this is of use to somebody or the other.
Cheers...