开发者

Include binary data in XML file

开发者 https://www.devze.com 2023-02-01 04:28 出处:网络
We need to upload the attachments(for ex. word document) in xml f开发者_高级运维ile. Is there any way to attach this? Any sample code using c# will be appreciated.Have a look at this article:

We need to upload the attachments(for ex. word document) in xml f开发者_高级运维ile. Is there any way to attach this? Any sample code using c# will be appreciated.


Have a look at this article: http://www.codeproject.com/KB/XML/xml_serializationasp.aspx it describes saving bmp images into and out of xml by converting them to byte arrays. I suspect a similar method would work for other files.


An alternative is to store a uri to the resource instead of attempting to include it within the XML.

<?xml version="1.0"?>
<item>
    <attachment type="word">http://path.to/document</attachment>
</item>

The client is going to have to do some work to either unencode or fetch the attachment anyway so doing it this way could save a lot of pain.

0

精彩评论

暂无评论...
验证码 换一张
取 消