3

I am using Simple HTML DOM to get content from a website. However some of the images do not display because they are set as backdroung images from an external so I have called this in also.

However the image dose not have the full path.

<style>    
div.spriteImgSmall { background: url(/images/css_sprites/film_sprites/smallimages_sprite.jpg); } 
    div.spriteImgSmall_17826 { background-position: -0px -0px; width: 86px; height: 64px; }
</style>

There are no head or body tags as this is part of a facebook app. How could I use Simple HTML DOM to add on the base url to the path?

hakre
  • 193,403
  • 52
  • 435
  • 836
Keith
  • 73
  • 7

1 Answers1

2

DOM deals with structured HTML, however what you've got there is CSS, which for DOM is just unstructured text. So probably your best approach would be:

  1. Parse HTML DOM, find style tags
  2. Take contents of the style tag by using something like (string)$dom->style
  3. Parse the content with preg_match(), looking for url(blah-blah)
StasM
  • 10,593
  • 6
  • 56
  • 103
  • Thanks for your help. I was working on preg_match and found the solution when I stumbled on the a way to do it through the simple html dom. Funny I searched this whole site and found nothing before asking. http://stackoverflow.com/questions/3329499/convert-a-relative-url-to-an-absolute-url-with-simple-html-dom – Keith Dec 11 '10 at 19:56