473,397 Members | 2,068 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,397 software developers and data experts.

http xml encoding

I'm sending an xml stream through an http connection to my webserver.
Since some of the xml data will have the same characters as the 'xml
characters'(i.e <,>, etc...), I need the xml to be encoded for the
server. For example, is it a standard practice to encode the >
characer as &gt; in the xml ?

Will this do it ?

Dim oEncoder As New System.Text.ASCIIEncoding
requestData = oEncoder.GetBytes(xmlString)

if this is not the correct way to do it, could someone please show me
the correct way ?

Sorry to add another topic, but also this xml data will contain byte
data from a scanned image in one of the fields, so there is a
possibility it will have chr(0) in the data also. If I need to
prepend data to the xml string (so I need to make a copy of it) can I
just assign it to another string or will it get truncated at the
chr(0) like it would in C.

Thanks,
mark
Nov 21 '05 #1
1 2186
Mark,

See for your first problem this thread where Ger had in my opinion the same
goals as you
http://tinyurl.com/6t4ne

For your second problem you first need to serialize your picture what is not
to difficult, see the sample I once made bellow. (and the deserialize is as
well in it)

\\\Needs a form with a picturebox and 1 button
Private Function SerializeByte(ByVal _
imagestring As Byte()) As String
Dim bf As New Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim mem As New IO.MemoryStream
bf.Serialize(mem, imagestring)
Return Convert.ToBase64String(mem.ToArray())
End Function
Private Function DeserializeString(ByVal _
imagestring As String) As Byte()
Dim bf As New Runtime.Serialization.Formatters.Binary.BinaryForm atter
Dim mem As New IO.MemoryStream(Convert.FromBase64String(imagestri ng))
Return DirectCast(bf.Deserialize(mem), Byte())
End Function
'Test program
Private fo As New OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
Dim abyt As Byte() = br.ReadBytes(CInt(fs.Length))
br.Close()
Dim myresultstring As String = SerializeByte(abyt)
Dim abyt2 As Byte() = DeserializeString(myresultstring)
Dim ms As New IO.MemoryStream(abyt2)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
///

I hope this helps?

Cor

"Mark" <ma*****@yahoo.com>
I'm sending an xml stream through an http connection to my webserver.
Since some of the xml data will have the same characters as the 'xml
characters'(i.e <,>, etc...), I need the xml to be encoded for the
server. For example, is it a standard practice to encode the >
characer as &gt; in the xml ?

Will this do it ?

Dim oEncoder As New System.Text.ASCIIEncoding
requestData = oEncoder.GetBytes(xmlString)

if this is not the correct way to do it, could someone please show me
the correct way ?

Sorry to add another topic, but also this xml data will contain byte
data from a scanned image in one of the fields, so there is a
possibility it will have chr(0) in the data also. If I need to
prepend data to the xml string (so I need to make a copy of it) can I
just assign it to another string or will it get truncated at the
chr(0) like it would in C.

Thanks,
mark

Nov 21 '05 #2

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

Similar topics

30
by: Anon | last post by:
If Http headers specify the character encoding, what is the point of the Meta tag specifying it?
2
by: Robert | last post by:
I'm new to XML. I need to have my asp.net page accept an XML document sent via HTTP (from a Java app), process some info and send back a response as XML. I continue to get back an error on my...
3
by: ME | last post by:
Hi; I am getting "Unhandled Exception: System.Net.WebException: The remote server returned an erro r: (401) Unauthorized." when I am trying to get a page via post. Code follows...
0
by: Owen | last post by:
Hello everyone, I am using VS.NET 2003(Trandition Chinese) Edition, and httpLook software for checking http requests. I found a problem that the following programs don't really "POST". These...
0
by: Chris McDonough | last post by:
ElementTree's XML serialization routine implied by tree._write(file, node, encoding, namespaces looks like this (elided): def _write(self, file, node, encoding, namespaces): # write XML to file...
2
by: Paul Phillips | last post by:
Has anyone been able or is having trouble with setting the Content-Encoding to a value in the headers collection of an HTTPWebRequest object. I am trying to post a RosettaNet message to a trading...
3
by: webEater | last post by:
Hey, I am writing a file that reads in an external file in the web and prints it out including the response header of the http protocol. I do this to enable cross domain XMLHttpRequests. I...
1
by: ujjwaltrivedi | last post by:
Hey guys, Can anyone tell me how to create a text file with Unicode Encoding. In am using FileStream Finalfile = new FileStream("finalfile.txt", FileMode.Append, FileAccess.Write); ...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am using ASP.Net 2.0 and VB.Net (although C#is ok also). I want to create an object/method/function that will take a URL as an input parameter and then return all of the HTML in that page. I...
2
by: Vladimir Ghetau | last post by:
Hi guys, This is a weird problem, and I'm not sure if I got it right. Just a practical example, that will describe my problem: I'm connecting to google.com host on port 80 using fsock open,...
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: 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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.