473,386 Members | 1,830 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,386 software developers and data experts.

write xml to memory instead of file



Hello all ,

I have this VB.NET code , it generates a xml document that is then
read into a string and send to a unix webservice

Dim XMLHess As New XmlTextWriter("test.xml",
System.Text.Encoding.GetEncoding("iso-8859-1"))

With XMLHess
.Formatting = Formatting.Indented
.Indentation = 2
.WriteStartDocument()
.WriteStartElement("onlinebestellung")
.WriteStartElement("request")
.WriteElementString("cmd", "INQUIRY") 'INQUIRY 'ORDER
.WriteEndElement()
.WriteStartElement("positionen")
'loop voor de artikelen
.WriteStartElement("artikel")
.WriteElementString("bestellartikelnummer","24.011 0-0116.1")
.WriteElementString("bestellmenge", "1")
.WriteElementString("hersteller", "ATE")
.WriteEndElement()
'einde artikelloop
.WriteEndDocument()
.Close()
Dim sRead As New StreamReader("test.xml")
strXML = sRead.ReadToEnd()
End With
MsgBox(strXML)

Dim shopHess As New HessShop.ITiRepSrvservice

Dim strError As String, intReturn As Integer, intSucces As Integer

Debug.WriteLine(strXML)

intSucces = shopHess.XMLExecute("logoninfo", strXML, strError,
intReturn)

It is working fine however i do not want to generate a physical file
write to it and read it back , my server is a verry powerfull machine (
cluster server ) and i would like to generate the xml format in memory
and then output it to a string and send it to the webservice
Does someone have an idea what i need to modify to acomplish this ??

Michel ,


Nov 21 '05 #1
2 6445
Michel,

I find this the easiest ones

Serialize
\\\\
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)
///
I hope this helps a little bit?

Cor
Nov 21 '05 #2
Cor Ligthert wrote:
Michel,

I find this the easiest ones

Serialize
\\\\
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)
///
I hope this helps a little bit?

Cor


Cor ,, you are great

changed my code to this

Dim sw As New System.IO.StringWriter
Dim XMLHess As New XmlTextWriter(sw)

With XMLHess
.Formatting = Formatting.Indented
.Indentation = 2
.WriteStartDocument()
.WriteStartElement("onlinebestellung")
.WriteStartElement("request")
.WriteElementString("cmd", "INQUIRY") 'INQUIRY 'ORDER
.WriteEndElement()
.WriteStartElement("positionen")
'loop voor de artikelen
.WriteStartElement("artikel")
.WriteElementString("bestellartikelnummer","24.011 0-0116.1")
.WriteElementString("bestellmenge", "1")
.WriteElementString("hersteller", "ATE")
.WriteEndElement()
'einde artikelloop
.WriteEndDocument()
.Close()
strXML = sw.ToString
End With
MsgBox(strXML)
and it works exactly how i wanted
i was already considering to write the xml myself in a string but this
is much better :-)

regards and have a nice day

Michel

Nov 21 '05 #3

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

Similar topics

1
by: Ellixis | last post by:
Hello, How can I use fwrite() and fseek() in order to write data in the middle (or anywhere else) of a file without overwriting existing data ? People told me that I should load the file into...
9
by: R.Z. | last post by:
i was wondering whether it pays off in terms of memory use to maintain lots of empty deques (it would be convenient for my algorithms but memory use is more important). and does the size of a deque...
8
by: Patrik Malmström | last post by:
How do I read, write a file binary? I want to open, say, file.exe read it in to the program, then write it out to file2.exe. Like file copy, anyone have a code sample?
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
7
by: nass | last post by:
hi all, i am running slackware linux and need to use some function that will will enable me to write and read from a shared mem segment.. i am using open() , to open a file, and then use mmap to...
1
by: Iulian Ilea | last post by:
Hello, Let's say that I have a very big string to write into a file. If I concatenate strings and write the string into file at the end of processing than memory use will increase exponential....
4
by: apriebe47 | last post by:
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass ...
5
by: barnetod | last post by:
I am trying to open a text file designated by the user. Then I want to change all lower case values to capital letters. Then write file. I am stuck and can not change the characters or am...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
6
by: JT | last post by:
Hi, Here's my problem. I am using an obscure font in my Windows Form application, so I want to ensure that people using the application will have the text displayed as intended. I've included...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.