How to user Dataset ReadXMLSchema from XML String without XSD File
I have dataset which I used its GetXMLSchema and GetXML methods on. With those string values, how can I load a new dataset with the xml and its schema?
Here's my code so far:
Dim sXMLSchema As String = SomeDataSet.GetXMLSchema() Dim sXML As String = SomeDataSet.GetXML() Dim ds As New DataSet ' ds.ReadXmlSchema( ??? ) ' What goes here? ds.ReadXml(readerXML)
I think I need to convert sXMLSchema to some type of reader but I haven't been able to figure that part out yet. And I don't really want to have to save the schema to an XSD file just to use the ReadXmlSchema(FileName) overload.
Any suggestions on how to do this?
Thanks in advance.
.NET ProgrammingASP.NET
Last Comment
ZekeLA
8/22/2022 - Mon
muhammadyasir
try this code
private void ReadSchemaFromXmlTextReader ( ) { // create the DataSet to read the schema into. DataSet thisDataSet = new DataSet ( ); // set the file path and name. Modify this for your purposes. string filename = "mySchema.xml"; // create a FileStream object with the file path and name. System.IO.FileStream myFileStream = new System.IO.FileStream ( filename,System.IO.FileMode.Open ); // create a new XmlTextReader object with the FileStream. System.Xml.XmlTextReader myXmlTextReader = new System.Xml.XmlTextReader ( myFileStream ); // Read the schema into the DataSet and close the reader. thisDataSet.ReadXmlSchema ( myXmlTextReader ); myXmlTextReader.Close ( );}
Is there any way to do it without creating a file first?
I'm starting with a dataset. I want to pass that dataset using xml through a webservice. The client is not necessarily .NET so I can't / don't want to pass the dataset directly.
Thanks.
ZekeLA
ASKER
A developer friend of mine gave me the solution. I'll post it if it's not proprietary.
Open in new window