Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1> How do I add an image to an xml file.(syntax for it)?

2> How can you fetch that image from xml and show it when a button is clicked in asp.net(button in webpage)?
Posted
Updated 23-Feb-11 0:34am
v2

1 solution

XML doesn't support images. You have to store image as Base64 in XML.
This[^] might help you.

VB
Dim img As Image
Dim stream As New IO.MemoryStream()
Dim result As String
img = ' your image
img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg) ' or whatever format you want to use
result = Convert.ToBase64String(stream.ToArray)


and reverse to retrieve the image.
 
Share this answer
 
v3
Comments
Tarun.K.S 23-Feb-11 6:24am    
I have a small doubt. Converting images to string can make the size of XML large considering the fact that there are 500 images or more.
Sergey Alexandrovich Kryukov 23-Feb-11 22:27pm    
Sure. Idea of doing this is kind of silly, but this is OP's problem :-)
--SA
Dalek Dave 23-Feb-11 6:35am    
Good Call.
Sergey Alexandrovich Kryukov 23-Feb-11 22:28pm    
Sure, 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900