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

About thephpx

I am a freelance web application developer. I work with PHP5 and MySQL. Most of my projects are done using the codeIgniter framework.I am also working towards moving onto the Zend Framework. I follow agile development methodology and manage my projects throuh SCRUM based approach. Apart from being a developer I am also the CEO of a small web identity and application development firm located in dhaka, bangladesh. The firm known as 'implode impressions' also follows agile development techniques and works under the SCRUM based approach.

13 responses to “PHP Simple HTML DOM Parser, Codeigniter Integration

  1. Quite spiffy sir. Thanks. :-)

  2. Daniel

    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

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

  4. Niels

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

  5. Pingback: CodeIgniter 安裝 Simple HTML DOM Parser | 路破皮的部落格

  6. Hope it still working

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

  8. Mihajlo

    Works great!

    Thanks!

  9. Andreas Pollak

    Thanks!

  10. shuffledex

    codeigniter 2.0.* version?

  11. 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

  12. jamesv

    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

  13. 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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>