December 13th, 2012, 09:09 PM
Raeding in an image from html/xml
Hi I am uing Delphi XE2. If I read in a html file I can read the '<input name="ctl00$CB$ctl02$ctl02$txtValue"' as a value to a string then put the string into a Clientdataset.
What I want to do is the same thing but with an image reading it into a blob field.
<input type="image" name="ctl00$CB$ctl55$ctl02$btnViewImage"
Can anyone point me in the right direction
December 14th, 2012, 08:13 AM
You can translate and place the image content into TMemoryStream and then assign it to TBlobStream of your blob field.
See this tutorial on how to use TBlobStream to store (and load) images to (and from) database blob field.
December 16th, 2012, 08:30 PM
Reading html/Xhtml - continued
Hi, Thank you for the information. I am not sure how to read this html/xhtml.
Using TWebBrowser I have captured this text from a page.
I can read in Surname, first name Date of Birth as text into a Clientdataset.
What I want to do is be able to extract one of the images that appears on the webpage and then save it to a blob field.
My problem at this stage is getting the image. I am not sure how to get it.
This clearly is not right
Below is the html/Xhtml code of the line where I think the image I am after is. Note that the image has a unique number e.g 839956
<input type="image" name="ctl00$CB$ctl55$ctl02$btnViewImage" id="ctl00_CB_ctl55_ctl02_btnViewImage" title="View Image" class="imageBtn" src="../Images/View.GIF" onclick="return BlobToFile(this,839956);" style="border-width:0px;" />
December 17th, 2012, 12:53 AM
Since you are using TWebBrowser you actually might already had the image (unless you turned off display image in your Internet Explorer options). Because TWebBrowser simply a wrapper to IE. For this, you need to work trhough TWebBrowser DOM. find something like (not sure I got the name right, got no time to check. Sorry) IHtmlImage or might be IHtmlImgElement.
Another approach would be to specifically fetch (using the url you got) the image using simpler socket libraries. Like Indy, Synapse, or even one that coming with Windows, i.e. WinInet.
Last edited by Luthfi; December 17th, 2012 at 12:57 AM.