开发者

Include binary data in XML file

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜