Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create a stream from a string variable

1 view
Skip to first unread message

Joseph Rea, Accord Software

unread,
Mar 15, 2005, 3:41:06 PM3/15/05
to
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.

Peter Foot [MVP]

unread,
Mar 15, 2005, 4:05:30 PM3/15/05
to
You could use System.Text.Encoding.Unicode.GetBytes to get a byte array for
your string. Then create a new System.IO.MemoryStream from that.

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

"Joseph Rea, Accord Software"
<JosephReaAc...@discussions.microsoft.com> wrote in message
news:122B8D77-917C-4D15...@microsoft.com...

Ilya Tumanov [MS]

unread,
Mar 15, 2005, 4:14:41 PM3/15/05
to
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?=
<JosephReaAc...@discussions.microsoft.com>
> Subject: Create a stream from a string variable
> Date: Tue, 15 Mar 2005 12:41:06 -0800
> Lines: 18
> Message-ID: <122B8D77-917C-4D15...@microsoft.com>
> 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

Joseph Rea, Accord Software

unread,
Mar 15, 2005, 5:43:10 PM3/15/05
to
It's working great now. Thanks very much to both of you.

snatchblaster

unread,
May 2, 2009, 9:01:01 AM5/2/09
to
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.

Chris Tacke, eMVP

unread,
May 2, 2009, 10:31:39 AM5/2/09
to
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


"snatchblaster" <snatch...@discussions.microsoft.com> wrote in message
news:BAA0F67F-31D1-429E...@microsoft.com...

snatchblaster

unread,
May 2, 2009, 12:38:01 PM5/2/09
to
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.

Chris Tacke, eMVP

unread,
May 2, 2009, 3:42:25 PM5/2/09
to
You're right, I can't see any previous post from you.

Post the working and failing code.


--

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


"snatchblaster" <snatch...@discussions.microsoft.com> wrote in message

news:E5A31933-C498-4095...@microsoft.com...

0 new messages