Re: C# byte[] conversion to XML

  • Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date
N

Nicholas Paldino [.NET/C# MVP]

Msuk,

Does the byte stream already represent XML? If it does, then why not
just send that?

Or, are you trying to take the binary contents and place it into an XML
file? If that is the case, then you are going to have to base64 encode your
bytes, and the place that as the text for an element in your XML document.

Hope this helps.
 
J

Jon Skeet [C# MVP]

msuk said:
I am trying to take the binary contents and place them into a XML file. Can
you tell me how I can base64 encode the bytes?

Use Convert.ToBase64String.
 
N

Nicholas Paldino [.NET/C# MVP]

Msuk,

You can take your byte array and pass it to the static ToBase64String
method on the Convert class. You can then take the resulting string and add
it to an element in your XML.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

msuk said:
Hi,

I am trying to take the binary contents and place them into a XML file.
Can
you tell me how I can base64 encode the bytes?

Thanks

Nicholas Paldino said:
Msuk,

Does the byte stream already represent XML? If it does, then why not
just send that?

Or, are you trying to take the binary contents and place it into an
XML
file? If that is the case, then you are going to have to base64 encode
your
bytes, and the place that as the text for an element in your XML
document.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

msuk said:
All,

I have a file that has been loaded into a byte[] array and I wish to
output
the byte array into XML and send it to a VB6 COM component so that it
can
build the file and save it to disk. Does anyone know how I can take
the
byte[] in C# and produce the XML file.

Thanks
Msuk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top