How to display an image, embedded in XML, at a web

Results 1 to 2 of 2

Thread: How to display an image, embedded in XML, at a web

  1. #1
    Join Date
    Dec 1969

    Default How to display an image, embedded in XML, at a web

    Basic:<BR>I have an XML document loaded into an ASP page. The XML contains an image (binary data encoded in base64). I want the image to show on the website. How?<BR><BR>More detailed question:<BR>I&#039;m working on a system that uses XMLHTTP to get information to an ASP page. Now I want to be able to send images this way. I know how to embed images in an XML document (see, but when the ASP site at the clients side receives the XML document, how can I show the image? I can&#039;t just insert an url for the image, because the image file is very temporary and will be overwritten by another server application I have, which means that if I insert an url in the XML document the image will likely not be the same when the client browser gets it. It has to be embedded in the xml document.<BR><BR>I&#039;ve tried to use a div-tag that I try to update the innerHTML of, but that doesn&#039;t work. I mean, what should I put in there? I cannot put a &#060;img&#062; tag since there are no filename to give as src argument. I cannot either, of course, just insert the response since it&#039;ll just show rubbish (the gif-file as characters).

  2. #2
    Join Date
    Dec 1969

    Default RE: How to display an image, embedded in XML, at a

    To display an image you will need an &#060;IMG&#062; tag (or a style="background:..." or something like that). And for that you need another URL as the src attribute.<BR><BR>You can save the binary data to a file on your harddisk (somewhere below the root of your website), and place an &#060;IMG&#062; tag pointing to that file on your webpage. If you worry about a unique filename, you can name it using the current datetime in milliseconds, or using a large random number, or a GUID.<BR><BR>You can also use an &#060;IMG&#062; tag with the SRC attribute set to another asp page, where the binary data is read from the same xml document and then written to the client using Response.BinaryWrite.<BR><BR>Hmmmm, perhaps it is also possible to write a swf (flash movie) that takes a base64 string as input parameter and then shows the image. That way you can write the image as base64 to the same page, and it will still display the image.<BR>But I&#039;m no flash expert...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts