Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am in a fix. I want to embed a file in XML without using Base64 encoding. Any idea as how we can do it? We are mainly trying embed a .xls/.doc/.txt file.

Thanks!
Posted
Updated 10-May-11 3:09am
v6
Comments
Sandeep Mewara 9-May-11 7:04am    
What file? Can you be a little more clear. Further adding the scenario on what are you trying and why would surely help members to answer.
Sergey Alexandrovich Kryukov 9-May-11 11:01am    
I answered as for .NET -- almost by accident. I noticed this is not tagged when my solution was almost written... :-<
--SA
Sandeep Mewara 9-May-11 11:12am    
Thats ok! :)
RedHearts2011 10-May-11 5:38am    
I have updated my question and tagged it accordingly. Sorry, for not being clear!

Why you even think about base64. If course you can embed the file in the assembly's executable model as is.

This is the instructions for .NET (sorry, but tag your questions accurately; what's your platform, language?!).

Do the following. Create a new .resx resource. In the resource designer page use "Add existing file". Choose your file by the browser, add. It will be: 1) copied to your project's directory structure where the resource file is, 2) automatically added to your project as a separate file, 3) added file will be referenced in your resource file.

Now, take a look of the auto-generated source code. It will show a static class with static property with the name based on your file name. Use it! You can parse the XML out of string embedded under the name is this variable.

Displaimer: I noticed that platform in not tagged, so I answered for .NET. If this is something else — sorry. Maybe the idea it self is useful. You need to tag the question accurately.

—SA
 
Share this answer
 
Well.. the XML is nothing but string so if you need to send anything inside XML it must be converted to string i.e. base64 so that at receiving end it again can be converted to 8x3.

but if its SOAP it can be done via attachments.
http://www.w3.org/TR/2000/NOTE-SOAP-attachments-20001211[^]

Thanks,
Hemant

Edit: (sending attachment with SOAP)

i've not tried but found this link:
http://msdn.microsoft.com/en-us/library/ms824597.aspx[^]

But below thread says DIME is outdated and suggested MOTM:
http://stackoverflow.com/questions/335688/soap-attachment-from-net-3-5-to-php-web-service[^]

with MOTM:
Sending Files in Chunks with MTOM Web Services and .NET 2.0[^]

But i'll say it all depends on the protocol you are using to send XML like SOAP supports attachments.

Hope it will help.
Thanks,
Hemant
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 9-May-11 21:17pm    
Base64 is mainly for coding binary files; no point to convert XML into base64. Embedding XML in resource as is is not a problem at all.
--SA
Hemant__Sharma 10-May-11 1:27am    
@SAKryukov - Yes sir :). i never said "convert XML into base64". "inside XML" - here i was referring to the binary data. And i'm here embedding binary into XML not XML into something.

Thanks,
Hemant
RedHearts2011 10-May-11 9:04am    
But .net doesn't support sending Soap with Attachment right?
Hemant__Sharma 10-May-11 14:23pm    
I've improved the solution with the links taking about .net possibilities of sending attachments with SOAP.

Thanks,
Hemant

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