Does someone here know a html parser library that will work with codeigniter?
Asked
Active
Viewed 8,919 times
2 Answers
16
I was able to figure out how to run Simple_html_dom php library on codeigniter
I copied the file Simple_html_dom.php to
/system/libraries
Then in my controller I call it using
require_once('Simple_html_dom.php');
To use it I initialized it using this line
$html = new Simple_html_dom();
Load a page or link using the line
$html->load_file('http://www.google.com');
and parse or find elements using this line
$html->find('table tr td')->plaintext;
works fine and fits right to what I needed to do.

Gerard Banasig
- 1,703
- 13
- 20
-
16Also, you can probably put it in /application/libraries instead of /system/libraries (I think that's the suggested practice). – Matthew Sep 04 '10 at 13:28
-
genius, it worked out for me. The only difference is I added the file to /application/libraries. I have also taken the liberty to edit the answer. Thanks to @Matthew – Harish Ninge Gowda Oct 09 '16 at 07:46
-
alright.... gooood! This will be a nice step for adding external library into any version of C.I. @Gerard... – gumuruh Dec 05 '21 at 05:59
6
Similar questions have been asked here and here
Hopefully that helps.
More possibilities include DOMDocument::loadHTML and PHP Simple HTML DOM Parser

Community
- 1
- 1

Blaine Lafreniere
- 3,451
- 6
- 33
- 55
-
Thanks a lot @jacolyte but those are native php libraries, I need one that will run with codeigniter's library system – Gerard Banasig Nov 20 '09 at 04:00
-
Most libraries can be used with CodeIgniter (I frequently use `markdown` and others). Just `require` them from a centra location (like `config/configure.php`), or place them in `libraries/` with a CI-style class wrapper. – Bruce Alderson Nov 20 '09 at 17:59
-
Why do you need one that 'will run with codeigniters library system' ? What difference does it make? – Jessedc Dec 04 '09 at 03:02
-
1a php library needs to be extended modified to fit the library structure of codeigniter http://codeigniter.com/user_guide/general/creating_libraries.html – Gerard Banasig Jan 22 '10 at 06:36