Include binary data in an XML file

We need to load the attachments (for example, a text document) into an xml file. Is there any way to attach this? Any sample code using C # would be appreciated.

+3
source share
2 answers

Take a look at this article: http://www.codeproject.com/KB/XML/xml_serializationasp.aspx it describes how to save BMP images in xml and from them by converting them into byte arrays. I suspect a similar method will work for other files as well.

+3
source

An alternative is to save the uri of the resource, rather than trying to include it in XML.

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

- , unencode, , .

0

Source: https://habr.com/ru/post/1781908/


All Articles