April 18, 2006

VB.NET/ASP.NET XML String to Dataset

Ok, I had to post this! This is how you can take an XML string and create a dataset from it. Couldn't find anything on Google so I hope this helps everyone!

strXML = "<your><xml><string>"

Dim XMLreader As StringReader = New System.IO.StringReader(strXML)

' Create the dataset
Dim newDS As DataSet = New DataSet
newDS.ReadXml(XMLreader)


Simple!!




2006-05-19T20:21:38.9490000-07:00
63.105.105.111

kick it on DotNetKicks.com

6 comments:

Alex said...

I don't think it worked...

David Green said...

It seems like it should work, I know I've done this kind of thing before...

My guess is your variable strXML in the example is not well formed XML syntax. If you ran your example, as is, you would no doubt run into weirdness.

Unknown said...

Please update your profile with the address your would like me to send your BEER to!

Thank you, works perfectly!

Unknown said...

What about the MSDN article "Loading a DataSet from XML"?
http://msdn2.microsoft.com/en-us/library/fx29c3yd.aspx

Madchops1 said...

Make sure you import the namespace system.IO to access the StringReader or you may encounter an issue.

- Karl Steltenpohl Develpment
- karls @ karlsteltenpohl.com

Anonymous said...

Its not working.. I have tried. Always dataset values showing "None" values.