perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Monday, 13 August 2007
 
NEWS
MSXML 4.0 SP2 now available!

 
MSXML
Basics
DOM
SAX
XPath
XSLT
Schemas
SOM
HTTP Access
.NET
Data Islands
Ask a Question
   Past Q&As
C++ Samples
DLL/Version Info
Reference Guide
Books
KB Articles
   HOW TO
   SAMPLE
   INFO
   BUG/PRB
   FIX
   Misc.
MSXML Tips
   August 2002
   September 2002
MSXML Tools

Microsoft XML Core Services


Go back to list of previously asked questions and answers

Question: I have an XML file that contains base64 encoded binary data (an image). I would like to write an ASP page that loads this XML file, gets the binary data and sends the image to the client and hence displayed on the browser.
Asked By: Guest
Viewed: 1058
Answer: It's very simple!

Here is the sample XML document that contains Base64 encoded binary data (an signature image). And here is the ASP code that loads this XML document using MSXML 4.0, gets the binary data from the SIGNATURE using nodeTypedValue property, sets the response conetent type and does a BinaryWrite on the Response stream.

<%
Option Explicit
Dim objXMLDoc 
	
Set objXMLDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
objXMLDoc.async = False
objXMLDoc.validateOnParse = True
	
'If you are loading remote XML Docs, uncomment the following line
'objXMLDoc.setProperty "ServerHTTPRequest", True
	
If objXMLDoc.load (Server.MapPath("bank.xml")) Then
		
	Dim SigNode
	Set SigNode = objXMLDoc.selectSingleNode("//SIGNATURE")
		
	If SigNode Is Nothing Then
		'Image not found!!
	Else
		Response.ContentType = "image/gif"
		Response.BinaryWrite SigNode.nodeTypedValue
	End If
Else
	'Do error handling using objXMLDoc.parseError
End If

%>

Now you can browse directly to this page or refer to this page as the value of src attribute of the IMG in any other Web page (do View Source on this page).


Go back to list of previously asked questions and answers
  Contact Us | E-mail Us | Site Guide | About PerfectXML | Advertise ©2004 perfectxml.com. All rights reserved. | Privacy