1

i have this html tag in my XML file

<text><![CDATA[<p><div style="text-align:justify">A certain compound has the molecular formula <img width="40" height="17" align="bottom" alt="mc001-2.jpg" src="@@PLUGINFILE@@/mc001-2.jpg" border="0"> If 10.0 g of the compound contains 5.62 g of X, the atomic mass of X is</div></p>]]></text>

and src attribute contain file name which if in another file tag in my XML file which is given below..

<file name="mc001-2.jpg" encoding="base64"> /9j/4AAQSkZJRgABAAEAIwAUAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCE
AAICAgICAgICAgICAgICAgICAgICAgICAgICAwMDAwMDAwMDBA UEAwQFBAMDBAYEBQUFBgYGAwQG
BwYGBwUGBgUBAgICAgICAgICAgUDAwMFBQUFBQUFBQUFBQUFBQ UFBQUFBQUFBQUFBQUFBQUFBQUF
BQUFBQUFBQUFBQUFBQUFBf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEBA QEB
AQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX 0BAgMABBEFEiExQQYTUWEHInEU
MoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OT pDREVGR0hJSlNUVVZXWFlaY2Rl
ZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqK mqsrO0tba3uLm6wsPExcbHyMnK
0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+foRAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYS
QVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJi coKSo1Njc4OTpDREVGR0hJSlNU
VVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5 iZmqKjpKWmp6ipqrKztLW2t7i5
usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/AABEIABAACwMBEQACEQEDEQH/
2gAMAwEAAhEDEQA/AP2M8S/Gm08Ba5f+HfG2g39nqWo3Gz4YQ6Jv1hvig7ou3SdMBSIQa1E+8 z2M
zKiWym9E7W8V09pNH2lem6VCnz4yDlzUbqP7vmfLXU3p9XjHlV eo0nh6l4zjy1MPOvcoxpTVSrNU
8I1H987tQnyrmpTjFOXtJSv9XhFSeIi1GnerGpTh6x4fn1u60X TbnxHp1lpGuT2sc2p6Xp2oPqtn
p1y/zG3jvHhhNzsBCmTy0DMGIGME7VIwhPkp1OdRSXNZpOVlzOKeqj zX5ea0uW3Mk7pYwlKScnTc
LuXLFtcyjzPk5+VuKnycvOoylFTuoylFKT801v4LeHvF+ra9rf ji7vPEmp3gW18KXCltKf4cadE8
M8B8NvA5ew1H7TBFdy6srfaJZIoVysMMUKYU4zoU1KjVdPFc7m 68bc+jkqcIqSlFUYwk4TotSp1+
ao66qRnyR2qTVVxp1KalhoxS9i78km4pTqVGmnKo5X9nNOMsPD lVDkqe0q1fTdBstS03RtNsNY1h
9f1OytIra81uWyt9On1SWMbftMtvb/uYpXADOIwqFixVEUhF3qzjUm5xpKne14xvyp2XNyqTlJR5
ruMXKTjG0XKTXM8KUHSh7N1HNRbs5W5uW75VJpJSko2UpKMVJp y5Y35V/9k=
</file>

i got the text OR say String after parsing the xml file in between CDATA type node but when i load it in WebView it makes a box for

<img width="40" height="17" align="bottom" alt="mc001-2.jpg" src="@@PLUGINFILE@@/mc001-2.jpg" border="0"> 

my problem is how to load above image tag in webView with its src attribute????????? also i am little bit confused with path given in src attribute.

screenshots are like this
enter image description here

Any help would be highly appreciated. Thanks in Advance

Irshad Khan
  • 794
  • 6
  • 21
  • where are you storing the images? are they on a server or are they bundled with your apk? – dymmeh Dec 19 '13 at 20:22
  • @dymmeh thanks for instant reply actually images are not at server i need convert the base code of images given in file tag in my XML file and show in the empty box. as shown in screenshot. see the tag under tag. its source attribute contain the same file name that given in file tag – Irshad Khan Dec 20 '13 at 03:45

2 Answers2

2

This looks like a Base64 Coded string that represents an image.

For loading such images in WebView, checkout this post.

Embedding Base64 Images

<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD" />
Community
  • 1
  • 1
Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
  • thanks for reply i want to load in WebView. my code for loding the string is **webView.loadDataWithBaseURL(null, employees.get(i).toString(), "text/html","UTF-8", null);** – Irshad Khan Dec 20 '13 at 04:00
  • yes it is working for me but under img tag my src attribute is looks like this **src="@@PLUGINFILE@@/mc001-2.jpg"** so its make an empty box. so how could i change my src attribute like yours programmatically Thanks – Irshad Khan Dec 20 '13 at 04:21
  • 1
    You can set the src value on the img tag through Javascript code. You will need to run a JS snippet on your HTML page, and call that from your Activity's code, and pass it. Do you have an HTML page for this view? – Kumar Bibek Dec 20 '13 at 04:24
  • No actually i parse the xml file using DOM parser and get content from tag(which is actually html code ) and then load the content in WebView. – Irshad Khan Dec 20 '13 at 04:42
  • You will definitely need some JS manipulations to achieve that in this situation then. – Kumar Bibek Dec 20 '13 at 04:44
0

I have got the solution of my problem, I have replace my src attribute

src="@@PLUGINFILE@@/mc001-2.jpg" by this 

src='data:image/png;base64,<!- Base64 code for image -->' 

and parsed it easily

and it worked for me Thanks for Replies.

Irshad Khan
  • 794
  • 6
  • 21