Although you can validate and create XML files through a schema, use them in comparison. NET class is more convenient, it will give you more flexibility to use.
Technical Toolbox: vb.net, XML, ado.net
Ado. NET provides a good capability to handle transformations between datasets and XML. You can pass VS. NET creates a dataset schema visually in XML. Like a document type definition (DTD), schemas allow you to validate and create XML files, but use them in comparison. NET class is more convenient, it will give you more flexibility to use.
But DTDs are not useless. It is widely used in non. NET program, the World Wide Web Consortium (consortium) standard for Internet and data conversion. In order to be able to achieve backwards (that is, not. NET) compatibility, the. NET Framework contains the ability to validate XML through DTDs.
However, even if you need to include a DTD in an output XML file generated by a Web program, this is not the case, or even if it exists, there is a lack of standard files to refer to.
And System.IO.FileStream object can help you solve this problem. You can create a FileStream and insert the DTD into your XML file, and one FileStream leads to two filestream―― that they get from the DTD and the dataset, respectively. You can design a DataSet schema with a DTD file and some sample XML. Vs. NET's visual Data set design interface makes this work easy, and DTD files stored in the application folder are included in the resulting XML.
This method uses many different kinds of filestreams. A FileStream (stream A) contains information about DTDs, and another FileStream (stream B) is used to create the final XML file. Stream a flows into stream B, the dataset flows directly into stream B, and Stream B closes and is stored as an XML file in your file system.
The first thing you should prepare is a dataset, and you can create a new schema-based dataset and then data binding. Next, the DTD file is read into a FileStream (Stream A). You can accomplish this by creating a FileStream object and a StreamReader object. To read a text file to FileStream by StreamReader:
Private Function GetDTD(DTDFilePath as string) _
As IO.FileStream
Dim fsDTD As System.IO.FileStream
Dim srDTD As IO.StreamReader
fsDTD = New IO.FileStream(DTDFilePath, _
IO.FileMode.Open)
srDTD = New IO.StreamReader(fsDTD)
GetDTD = fsDTD
End Function