How can I decode an image in BASE64 from an XML and display it in an HTML? I’m converting the XML to

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
Hi,
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
I developed an application page for SharePoint 2010 in VS2010 using C# to query a Web Service for an XML. This XML, basically a report, is converted to HTML using an <em style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent XSL
and XslCompiledTransform<strong style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent . [/i]This process works flawlessly.<strong style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <em style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent [/i]
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<strong style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <em style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent What is the problem?[/i]
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
The XML has an image in BASE64 and when I convert it to HTML the image is missing.
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
My XSL looks like this ( http://www.sendspace.com/file/prg164" style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent; color:#267cb2; text-decoration:none Download XSL Here ):
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <xsl:if test="foto
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <Foto>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <xsl:value-of select="foto"/>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent </Foto>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent </xsl:if>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <img id="Foto" language="javascript" onmouseover="this.style.cursor = hand" height="131" width="131" border="0" alt="Haga click para maximizar...
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <xsl:attribute name="src
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<em style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent DespFoto.AspX?dcr_no=<xsl:value-of select="DCRNO"/> // This is the picture!![/i]
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent </xsl:attribute>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <xsl:attribute name="onclick
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Foto_Click(<xsl:value-of select="DCRNO"/>)
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent </xsl:attribute>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent </img>
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
I found this code to decode BASE64:
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Public<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Function<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent FromBase64(<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent ByVal<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent base64 <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent As<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent String<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent ) <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent As<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Byte<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent ()
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent If<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent base64 <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Is<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Nothing<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Then<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Throw<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent New<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent ArgumentNullException(<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent "base64"<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent )
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Return<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent Convert.FromBase64String(base64)
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
<span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent <span style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent End
Function
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
Source: http://www.nonhostile.com/page-vb-net-base64-encoding-decoding.asp" style="margin:0px; padding:0px; border:0px; outline:0px; vertical-align:baseline; background-color:transparent; color:#267cb2; text-decoration:none http://www.nonhostile.com/page-vb-net-base64-encoding-decoding.asp
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
How can I decode and display the image in the HTML?
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
Do I need to modify the XSL?
<p style="margin-bottom:18px; padding-right:0px; outline:0px; font-size:13px; vertical-align:baseline; background-color:#f0f3f4; color:#222222; font-family:Segoe UI,Tahoma,Arial,Helvetica,sans-serif
Thanks in advanced.
<br/>

View the full article
 
Back
Top