XML string

G

Guest

Hi,
I have an XML string from which I would like to create a DataSet. This is
probably a stupid question, but how do I do this? - The XMLReader objects
always expect a stream or file as a parameter, but how do I parse XML from a
string that is getting passed in to me?

Thanks in advance!
Yuri
 
J

Jon Skeet [C# MVP]

YuriL said:
I have an XML string from which I would like to create a DataSet. This is
probably a stupid question, but how do I do this? - The XMLReader objects
always expect a stream or file as a parameter, but how do I parse XML from a
string that is getting passed in to me?

You can use StreamReader to create a TextReader from the string, then
pass that into DataSet.ReadXml.
 
M

Matt Berther

Hello YuriL,

[C#]
string s = "<someXml @foo='bar'/>";
XmlReader reader = new XmlTextReader(new StringReader(s));
 

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

Top