XML file as a string into a Dataset.

P

Paul Bromley

I suspect the anwer to this is going to be obvious, but can someone give me
a clue here as I am presently doing this in a roundabout way. I am using an
API that gives me an XML file as a string. I am presently using Streamwriter
to write an XML file to disk and then reading the XML file into a Dataset.

Best wishes

Paul Bromley
 
C

Cor Ligthert

Paul,

You mean
\\\
ds.WriteXML("path")
And
ds.ReadXML("path")
///

To do it to disk
or do you mean

\\\\
Dim sw As New System.IO.StringWriter
ds.WriteXml(sw)
Dim mystring As String = sw.tostring
///
Deserialize
\\\
Dim sr As New System.IO.StringReader(mystring)
Dim ds2 As New DataSet
ds2.ReadXml(sr)
///
To do it in memory?

I hope this helps a little bit?

Cor
 
H

Herfried K. Wagner [MVP]

Paul,

Paul Bromley said:
I suspect the anwer to this is going to be obvious, but can someone give me
a clue here as I am presently doing this in a roundabout way. I am using
an
API that gives me an XML file as a string.

\\\
Dim XmlString As String = ...
Dim d As New DataSet()
d.ReadXml(New StringReader(XmlString))
///
 
H

Herfried K. Wagner [MVP]

Addendum:

I forgot to add that you will have to import the 'System.IO' namespace in
order to use the code I posted. 'StringReader' is contained in this
namespace.
 
P

Paul Bromley

Many thanks Cor & Herfried for this - will try it a bit later tonight.
Ceratinly a lot easier than my code as I had to delete the file and then
checking the new file existed before loading it into the dataset each time
that I run the code.

Best wishes

Paul Bromley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top