Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

 

//convert xml string to dataset, and WriteXmlSchema to string

 

System.IO.

 

DataSet dsResponse = new DataSet();StringReader sr = new System.IO.StringReader(responseMessage);//System.IO.StreamReader sr = new System.IO.StreamReader(

dsResponse.ReadXml(sr);

System.Text.

 

StringBuilder builder = new System.Text.StringBuilder();// Create the StringWriter object with the StringBuilder object.

System.IO.

 

StringWriter writer = new System.IO.StringWriter(builder);// Write the schema into the StringWriter.

dsResponse.WriteXmlSchema(writer);

 

//put schema in string

 

string xmlSchema = writer.ToString(); Posted on Wednesday, September 13, 2006 1:41 PM XML & Datasets | Back to top


Comments on this post: convert xml string to dataset & WriteXmlSchema to string

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
Hi,
I have tried the same but it is giving an error
"data at root level is invalid"
Left by Mishra on Oct 16, 2007 7:07 PM

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
I bet your xml file that you are reading is not well formed. Check your xml file.
Left by SneakyMonki on Apr 10, 2008 6:30 AM

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
I dint get it
Left by smilu on Oct 27, 2008 6:58 PM

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
Your Coding is working fine

Thank u,

Thanks a lot

Left by Narendra on Oct 01, 2009 4:52 AM

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
Simple question - How do I take a string and convert it to an xml schema?
Left by Daniel on Sep 26, 2011 9:19 AM

# re: convert xml string to dataset & WriteXmlSchema to string
Requesting Gravatar...
I would say this will help others. I have a method that returns an object, which contains all the XML to be converted to DataSet. below is the code.

Object obj= (Object)abc(KEY);

//Converting the Object to String
String convertObject = (String)obj;

Reading the String in the StringReader
StringReader reader = new StringReader(convertObject);
//Creating the DataSet
DataSet ds = new DataSet();
//Reading the XML into DataSet.
ds.ReadXml(reader, XmlReadMode.ReadSchema);
Left by Mohammed Mohiuddin on Jul 17, 2012 9:10 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net