|
-
May 3rd, 2007, 07:52 AM
#1
Thread Starter
Fanatic Member
reading xml from a string
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 ?
-
May 3rd, 2007, 07:56 AM
#2
Lively Member
Re: reading xml from a string
I did something similar in my code:
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
.
.
.
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.
Gr,
Mightor
Last edited by mightor; May 3rd, 2007 at 07:59 AM.
Reason: Hit send too quickly.
What the world needs is more geniuses with humility, there are so few of us left.
If my post was accidentally useful, please rate it as such, thanks!
Mon aéroglisseur est plein des anguilles.
-
May 3rd, 2007, 08:08 AM
#3
Thread Starter
Fanatic Member
Re: reading xml from a string
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
-
May 3rd, 2007, 08:18 AM
#4
Lively Member
Re: reading xml from a string
 Originally Posted by venerable bede
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
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
What the world needs is more geniuses with humility, there are so few of us left.
If my post was accidentally useful, please rate it as such, thanks!
Mon aéroglisseur est plein des anguilles.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|