Click here to Skip to main content
15,850,753 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Is there any way to read the XML file into datatable which is creating in runtime ,without saving xml file into local drive?

See Here also[^]

1 solution

DataSet ds = new DataSet(); 
ds.ReadXml(new XmlTextReader(new StringReader(xml)));

DataTable books = ds.Tables[0];


XmlDocument xdoc = MethodReturnsXmlDocument();

DataSet ds = new DataSet()
ds.ReadXml(new XmlNodeReader(xdoc));
Share this answer
P_A_1 15-Jun-12 5:38am    
Hi i saw ur code and doc.Load is nothing but, opening the saved file in the drive....
I mean it is simply opening it but what i need is i will create the xml file from database with the help of web service and i need to read it without saving it any where....

I hope u understand it....
Manas Bhardwaj 15-Jun-12 5:43am    
You are correct. I missed the file thingy.
Improved my solution. Pleasee see if it helps.
P_A_1 15-Jun-12 5:58am    
Hai , here u wrote like this "new StringReader(xml)"...

What Do u mean by this...

Should i need to convert the my xmldocument to any stringreader type???

I hope u understand it....
Manas Bhardwaj 15-Jun-12 6:12am    
I thought you have xml in string format. And you can always get the string xml out of xmldocument with document.OuterXml method.
Anyways, modified my solution to load xml document in dataset.
P_A_1 15-Jun-12 6:16am    
Thanks for reply and ur second solution is much better than first one and first one solved my task and

a heartfull thanks to u for saving my most valuable time bye... ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900