473,378 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

string to a stream

I'm baffled! Some time back on a webcast I saw how to convert a string to a
stream but now I can't remember how. I pulling a string from a IBM Message
Queue which is an XML string, convert that to a stream, then send it to the
load method of an XMLDocument object. Thanks for your help.
Nov 23 '05 #1
5 997
You shouldn't need a stream if you have the xml in a string already:

Dim xTest As New Xml.XmlDocument
Dim file As New System.IO.StreamReader("C:\Test1.xml")
Dim sData As String = file.ReadToEnd()

xTest.LoadXml(sData)

This works for me.

"prefersgolfing" <pr************@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
I'm baffled! Some time back on a webcast I saw how to convert a string to
a stream but now I can't remember how. I pulling a string from a IBM
Message Queue which is an XML string, convert that to a stream, then send
it to the load method of an XMLDocument object. Thanks for your help.

Nov 23 '05 #2
I have this function but note that it hasn't been fully tested.

Private Function StringToStream(ByVal strInString As String) As System.IO.Stream
'; Purpose: converts a string to a stream
'; Note: Not fully tested

Dim byt(strInString.Length - 1) As Byte
byt = System.Text.Encoding.UTF8.GetBytes(strInString)
Dim stm As System.IO.Stream = New System.IO.MemoryStream(strInString.Length)
stm.Write(byt, 0, byt.Length)
stm.Position = 0

Return stm

End Function
"prefersgolfing" <pr************@hotmail.com> wrote in message news:uw**************@TK2MSFTNGP12.phx.gbl...
I'm baffled! Some time back on a webcast I saw how to convert a string to a
stream but now I can't remember how. I pulling a string from a IBM Message
Queue which is an XML string, convert that to a stream, then send it to the
load method of an XMLDocument object. Thanks for your help.

Nov 23 '05 #3
The idea here is I don't want to use a file. I don't need to use a file. I
have a string and want to convert that to a stream.

"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
You shouldn't need a stream if you have the xml in a string already:

Dim xTest As New Xml.XmlDocument
Dim file As New System.IO.StreamReader("C:\Test1.xml")
Dim sData As String = file.ReadToEnd()

xTest.LoadXml(sData)

This works for me.

"prefersgolfing" <pr************@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
I'm baffled! Some time back on a webcast I saw how to convert a string to
a stream but now I can't remember how. I pulling a string from a IBM
Message Queue which is an XML string, convert that to a stream, then
send it to the load method of an XMLDocument object. Thanks for your
help.


Nov 23 '05 #4
Bryan,

My apologies. I didn't read your comment under the header and didn't notice
that you called the .LoadXML method. This works perfectly. Thanks!

"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
You shouldn't need a stream if you have the xml in a string already:

Dim xTest As New Xml.XmlDocument
Dim file As New System.IO.StreamReader("C:\Test1.xml")
Dim sData As String = file.ReadToEnd()

xTest.LoadXml(sData)

This works for me.

"prefersgolfing" <pr************@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
I'm baffled! Some time back on a webcast I saw how to convert a string to
a stream but now I can't remember how. I pulling a string from a IBM
Message Queue which is an XML string, convert that to a stream, then
send it to the load method of an XMLDocument object. Thanks for your
help.


Nov 23 '05 #5
You're welcome! I can count you as my first successful assistance on this
newsgroup! (Can I have my MVP Title now??!! Just kidding!)

"prefersgolfing" <pr************@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
Bryan,

My apologies. I didn't read your comment under the header and didn't
notice that you called the .LoadXML method. This works perfectly. Thanks!

"Bryan Dickerson" <tx******@netscape.net> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
You shouldn't need a stream if you have the xml in a string already:

Dim xTest As New Xml.XmlDocument
Dim file As New System.IO.StreamReader("C:\Test1.xml")
Dim sData As String = file.ReadToEnd()

xTest.LoadXml(sData)

This works for me.

"prefersgolfing" <pr************@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
I'm baffled! Some time back on a webcast I saw how to convert a string
to a stream but now I can't remember how. I pulling a string from a IBM
Message Queue which is an XML string, convert that to a stream, then
send it to the load method of an XMLDocument object. Thanks for your
help.



Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: David Rubin | last post by:
I looked on google for an answer, but I didn't find anything short of using boost which sufficiently answers my question: what is a good way of doing string tokenization (note: I cannot use boost)....
16
by: Der Andere | last post by:
During every iteration in a loop, I need to convert a double value into a char*. Simple type-casting did not work, so I thought of using stringstreams. However, the stream would have to be...
15
by: zealotcat | last post by:
Hi, all: I want to implement a function (using std::string and std::vector) split a string contain special token into vector. eg: string = "alex delia john" ==> vector = "alex"; vector =...
3
by: Chrigel | last post by:
Hi all, We have problems deseralizing objects previously serialized as XML. This did work fine with .NET 1.1 but since we have installed SP1, deserializing fails (but serializing works). The...
7
by: Donovan | last post by:
I can't believe this is causing me as much difficulty as it is, but I have an Infragistics UltraTreeview control that I want to persist whatever the user has in the tree. It has a method SaveAsXml...
4
by: TT (Tom Tempelaere) | last post by:
Hey there, I need a string stream, but I can't find one in .NET. I thought StringWriter would derive from Stream, alas it doesn't do so. Which leads me to my next question: What is the purpose...
6
by: Marco Herrn | last post by:
Hi, I need to serialize an object into a string representation to store it into a database. So the SOAPFormatter seems to be the right formatter for this purpose. Now I have the problem that...
4
by: Emilio | last post by:
Question about Shared Sub Connect(server As , message As ) Why is in square brackets? Is it like Shared Sub Connect(server() As String, message() As String)
6
by: fnoppie | last post by:
Hi, I am near to desperation as I have a million things to get a solution for my problem. I have to post a multipart message to a url that consists of a xml file and an binary file (pdf)....
11
by: Sudzzz | last post by:
Hi, I'm trying to convert a string something like this "{201,23,240,56,23,45,34,23}" into an array in C++ Please help. Thanks, Sudzzz
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.