如何在不使用Base64编码的情况下将文件嵌入XML? [英] How to embed file in XML without using Base64 encoding?

查看:82
本文介绍了如何在不使用Base64编码的情况下将文件嵌入XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经解决了.我想在不使用Base64编码的情况下将文件嵌入XML.关于我们如何做到的任何想法?我们主要是尝试嵌入.xls/.doc/.txt文件.

谢谢!

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!

推荐答案

为什么还要考虑base64.如果可以的话,您可以按原样将文件嵌入到程序集的可执行模型中.

这是.NET的说明(很抱歉,但是请准确标记您的问题;您的平台是什么,语言是什么!!).

请执行下列操作.创建一个新的.resx资源.在资源设计器页面中,使用添加现有文件".通过浏览器选择文件,添加.它将是:1)复制到资源文件所在项目的目录结构中,2)作为单独文件自动添加到项目中,3)资源文件中将引用添加的文件.

现在,看一下自动生成的源代码.它将显示一个具有静态属性的静态类,其名称基于您的文件名.用它!您可以从该变量名下嵌入的字符串中解析出XML.

Displaimer :我注意到该平台未标记,因此我为.NET回答.如果还有其他事情,对不起.也许它本身的想法是有用的. 您需要准确地标记问题.

—SA
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


嗯.XML就是字符串,因此,如果您需要在XML内部发送任何内容,则必须将其转换为字符串,即base64,以便在接收时再次将其转换为8x3.

但如果是SOAP,则可以通过附件完成.
http://www.w3.org/TR/2000/NOTE-SOAP-attachments-20001211 [^ ]

谢谢,
赫曼特

(使用SOAP发送附件)

我没有尝试过,但是找到了此链接:
http://msdn.microsoft.com/en-us/library/ms824597.aspx [ ^ ]

但是下面的线程说DIME已过时,建议使用MOTM:
http://stackoverflow.com/questions/335688/soap-attachment-from-net-3-5-to-php-web-service [使用MTOM Web服务和.NET 2.0批量发送文件 [
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

(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


这篇关于如何在不使用Base64编码的情况下将文件嵌入XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆