Create a stream from a string variable

G

Guest

Hi All.

Although this may be a very simple thing to do, I am having great difficulty
creating a stream from a string variable. In my vb.net CF (WinCE)
application, I have a string variable containing an XML document that I want
to load into a dataset. I see that there was a previous post related to this
("Read a dataset from a stream"), and I've tried to follow these
instructions, but to no avail. I've also tried cheating and just reading the
string directly into the XMLTextReader, but that throws an exception as well
(System.ArgumentException).

I can't seem to find the right implementation of the Stream class that will
read my string variable. I would appreciate it if anyone could tell me how to
load my string variable into the appropriate Stream object so that it can be
read by the XMLTextReader, which in turn will be passed to the
DataSet.readXML(XMLReader reader), as per the previous post I mentioned.

Thanks very much in advance.
 
I

Ilya Tumanov [MS]

How about this:

ds.ReadXml(new XmlTextReader(new StringReader(myStringWithXml)));

Best regards,

Ilya


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
G

Guest

It's working great now. Thanks very much to both of you.


"Ilya Tumanov [MS]" said:
How about this:

ds.ReadXml(new XmlTextReader(new StringReader(myStringWithXml)));

Best regards,

Ilya


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Create a stream from a string variable
thread-index: AcUpn0+SMhBEn8hnTyGIThFT7biSBQ==
X-WBNR-Posting-Host: 209.112.24.236
From: =?Utf-8?B?Sm9zZXBoIFJlYSwgQWNjb3JkIFNvZnR3YXJl?=
Subject: Create a stream from a string variable
Date: Tue, 15 Mar 2005 12:41:06 -0800
Lines: 18
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA
03.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:73294
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi All.

Although this may be a very simple thing to do, I am having great difficulty
creating a stream from a string variable. In my vb.net CF (WinCE)
application, I have a string variable containing an XML document that I want
to load into a dataset. I see that there was a previous post related to this
("Read a dataset from a stream"), and I've tried to follow these
instructions, but to no avail. I've also tried cheating and just reading the
string directly into the XMLTextReader, but that throws an exception as well
(System.ArgumentException).

I can't seem to find the right implementation of the Stream class that will
read my string variable. I would appreciate it if anyone could tell me how to
load my string variable into the appropriate Stream object so that it can be
read by the XMLTextReader, which in turn will be passed to the
DataSet.readXML(XMLReader reader), as per the previous post I mentioned.

Thanks very much in advance.
 
S

snatchblaster

I'm trying to do it with XMLdocument.Load method, and the second suggestion
isn't working for me. as for the suggestion, I am clueless what is being
suggested there.
 
C

Chris Tacke, eMVP

And since you didn't include the original post with your reply, those of us
using NNTP readers have no clue what you're talking about.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
S

snatchblaster

You act is if you cannot open up the post before mine, but to reiterate. I
am trying to load an XmlDocument with .Load from a URL. I set the URL within
qoutes and it works fine, but if i set the URL in a string, and then attempt
to use the string variable it gives me a null object error. I have tried
StringWriters and such and have had no success. I'm not sure if I have to
create an object a certain type of way or what.
 

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