#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    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

    Terry
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    3
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    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.
    Something like

    Image1.Picture.Graphic.LoadFromStream(this,839956)

    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;" />
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    3
    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 16th, 2012 at 11:57 PM.

IMN logo majestic logo threadwatch logo seochat tools logo