We need to upload the attachments(for ex. word document) in xml file. Is there any way to attach this? Any sample code using c# will be appreciated.
-
1This question doesn't make any sense. What would an XML file with an attachment look like? Once you can show me such an XML file, we can talk about how to create one.John Saunders– John Saunders2010-12-23 20:12:41 +00:00Commented Dec 23, 2010 at 20:12
-
Upload from where to where? In what XML file? Can you elaborate your question?Albin Sunnanbo– Albin Sunnanbo2010-12-23 20:13:20 +00:00Commented Dec 23, 2010 at 20:13
-
My main requirement is sharing the information/data across the platform/application without using web services (becuase the receiver application wont support web service)Prakash Mani– Prakash Mani2010-12-23 20:31:29 +00:00Commented Dec 23, 2010 at 20:31
Add a comment
|
2 Answers
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.
1 Comment
Steven Sudit
This is not a great answer, because base 64 is so inefficient in terms of both time and space. SOAP supports binary formats such as DIME, which would work better here.
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.