Re: http xml encoding
From: Cor Ligthert (notfirstname_at_planet.nl)
Date: 09/20/04
- Next message: Cor Ligthert: "Re: talking to forms"
- Previous message: Cor Ligthert: "Re: View Thumbnails like in windows explorer"
- In reply to: Mark: "http xml encoding"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 20 Sep 2004 07:40:41 +0200
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.BinaryFormatter
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.BinaryFormatter
Dim mem As New IO.MemoryStream(Convert.FromBase64String(imagestring))
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" <marfi95@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 > 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
- Next message: Cor Ligthert: "Re: talking to forms"
- Previous message: Cor Ligthert: "Re: View Thumbnails like in windows explorer"
- In reply to: Mark: "http xml encoding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|