Click here to Skip to main content
15,790,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to Convert a xml data into blob in c#. is that possible ?

Reason that my xml data size is high if i can convert it to blob then i will store the blob data into a table later i can use it in backend after converting it to xml.

What I have tried:

I've tried blob to xml conversion in backend it dint took much time. so now i want to know xml to blob conversion possible in c# or not
Updated 9-May-18 23:08pm
Wendelius 10-May-18 2:59am    
Are you referring to Oracle BLOB?
rajah rajah 10-May-18 4:33am    
BLOB in sql

XML data is just formatted text, and a "blob" is normally just binary data, so the conversion is pretty simple:
string s = ...
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
And to reverse it:
byte[] bytes = ...
string s = System.Text.Encoding.UTF8.GetString(bytes);
Share this answer
If you are using .NET 4 you can use the .NET zip functionality to compress the XML and store the zipped file as a BLOB, see: ZipFile Class (System.IO.Compression)[^]
Share this answer
i want to Convert a xml data into blob in c#. is that possible ?

There is no conversion to do because xml and blob are essentially the same thing.
Any file can be handled as a blob, just as any string or byte array.
Binary large object - Wikipedia[^]
Share this answer
[no name] 10-May-18 15:50pm    
Don't see a reason here for a one, try to compensate
Patrice T 10-May-18 17:23pm    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900