PHP Simple HTML DOM Parser, Codeigniter Integration

Hi all,

I came across “Simple HTML DOM Parser” recently that allows jQuery like DOM selection. This function is quite handy to do some kungfoo DOM manipulation on the fly!

I needed to use it on codeIgniter so modified the files and integrated it into a single codeIgniter library. The original files can be accessed from here its sourceforge project page. For the codeigniter version of the library click here.

  1. $this->load->library(‘domparser’);
  2. $html = $this->domparser->file_get_html(‘http://www.google.com/’);
  3. $rank = $html->find(‘b.gb1′);
  4.  
  5. print_r($rank); // will show all content of tag with class gb1

For further utility functions of the DOM parser visit this link.

Feel free to comment or contact me directly for any query.

take care,

thephpx

Share

Tagged: , ,

Comments: 13

  1. Kyle Farris October 26, 2009 at 02:48

    Quite spiffy sir. Thanks. :-)

  2. Daniel March 5, 2010 at 20:46

    Hey,

    Thanks for the files… am about to test it now. Will post back if any problems

    Do you have any idea what version of CI you modified the files for?

    fingers crossed : )

  3. Oliver July 26, 2010 at 05:38

    Trying to run this on godaddy and it appears to be freezing up on the library load.
    Any idea why?

  4. Niels August 27, 2010 at 16:55

    Thanks a lot! Fortunately I found your website before I was going to do this by myself ;)

  5. Owner May 14, 2011 at 10:07

    Hope it still working

  6. Owner May 14, 2011 at 10:43

    it working. clicking again at google adv – be happy and rich

  7. Mihajlo July 22, 2011 at 15:11

    Works great!

    Thanks!

  8. Andreas Pollak August 7, 2011 at 21:15

    Thanks!

  9. shuffledex August 25, 2011 at 20:27

    codeigniter 2.0.* version?

  10. thephpx August 25, 2011 at 21:40

    hi shuffledex,

    If its version compatibility you looking for, I guess it will still work on the latest one out, but it was originally implemented for codeigniter 2.0 or you can say 2.0.0

    thanks,

    faisal ahmed

  11. jamesv November 7, 2011 at 22:47

    I’m using CI 2.0.3 and it did not work. I always get “No such file or directory” but when I use simple_html_dom.php the url I’m trying to get is fetched. BTW where did you put the domparser.php? I put it in system/libraries

  12. thephpx November 22, 2011 at 02:58

    Hi James,

    Sorry about the delayed response and tes you are suppose to put the library at the application/libraries/ folder. The given library here was tested on 1.7.3 and was not tested on 2.0.3

    So, not away of any issues regarding the latest release :(

    thanks,

    faisal ahmed

Leave a Reply

Your email address will not be published. Required fields are marked *

*