all groups > dotnet xml > february 2006 >
You're in the

dotnet xml

group:

How to populate a dataset from an XML formated String


How to populate a dataset from an XML formated String paumierj NO[at]SPAM hotmail.com
2/17/2006 1:56:56 AM
dotnet xml:
Hi there

Here's my question :
I'd like to populate a dataset from an XML string, ie:

Dim sXmlString As String
sXmlString = "<root type='E-Form'><question label='This is my first
question'></question><question label='This is my second
question'></question></root>

Any idea to achieve this ?

Thanks in advance,
J.Philippe
Re: How to populate a dataset from an XML formated String kahtava NO[at]SPAM gmail.com
2/17/2006 2:39:37 AM
Sure... :) Take a look at the System.IO.StringReader and the
DataSet.ReadXml Method..

Source code is from the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconloadingdatasetfromxml.asp

DataSet myDS = new DataSet();
DataTable myTable = new DataTable("table1");
myTable.Columns.Add("col1", typeof(string));
myDS.Tables.Add(myTable);

string xmlData =
"<XmlDS><table1><col1>Value1</col1></table1><table1><col1>Value2</col1></table1></XmlDS>";

System.IO.StringReader xmlSR = new System.IO.StringReader(xmlData);

myDS.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
Re: How to populate a dataset from an XML formated String paumierj NO[at]SPAM hotmail.com
2/17/2006 3:02:00 AM
Thanks a lot !
have a nice day.

Regards,
J.Philippe
AddThis Social Bookmark Button