I have a string which contains XML and would like to read that xml into a datatable but for the life of me cant figure out how.
Any Ideas folks ?
Printable View
I have a string which contains XML and would like to read that xml into a datatable but for the life of me cant figure out how.
Any Ideas folks ?
I did something similar in my code:
Then you can extract the nodes and do with them as you please. Please note that the last couple of lines are very specific to my app.vb Code:
Dim sr As New System.IO.StringReader(_xmlString) ' The XmlTextReader Dim xr As New System.Xml.XmlTextReader(sr) ' The XmlDocument Dim serverStatus As New System.Xml.XmlDocument serverStatus.Load(xr) Dim serverNodes As System.Xml.XmlNodeList = serverStatus.SelectNodes("rs/r") Dim currentServer As System.Xml.XmlNode . . .
Gr,
Mightor
I'm a bit lost with that.
I need to read it into a datatable and the datatable overloads will take the following:
- string filename
- System.io.stream stream
- System.io.textreader reader
- xmlreader reader
Quote:
Originally Posted by venerable bede
vb Code:
Dim sr As New System.IO.StringReader(yourxmlstring) Dim xr As New System.Xml.XmlTextReader(sr) Dim yourDataTableInstance As New DataTable yourDataTableInstance.ReadXml(xr)
That should do the trick. It turns the String into a StringReader and then feeds that to a XmlTextReader which is fed to ReadXml.
Gr,
Mightor