nkoronka Posted January 30, 2011 Share Posted January 30, 2011 Hi there (first post), I'm trying to learn how to manipulate html with PHP and DOM. I'm fairly new to this. The problem I seem to be having seems to be server related. I've spoken to the support people and they say they don't support simple html DOM and so when I try to call- file_get_html() fatal errors occur. I wonder if someone could point me in the right direction here- are there any available hosts that will support simple html DOM? Any advice appreciated. If you need more info let me know. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/ Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 we need to see 1. the exact error and 2. the code causing it, including code BEFORE it happens. Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167299 Share on other sites More sharing options...
nkoronka Posted January 30, 2011 Author Share Posted January 30, 2011 Quite right, ok here's the error and code- Fatal error: Call to a member function find() on a non-object in /home/histo760/public_html/findlinks.php on line 10 <?php // Create DOM from URL or file $html = file_get_html('http://www.google.com/'); // Find all links foreach($html->find('a') as $element) echo $element->href . '<br>'; ?> Cheers Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167308 Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 sorry, i have never used simple html dom. but apparently you download it and include() it. it doesn't need to be compiled within php, so the host you use shouldn't matter. http://sourceforge.net/projects/simplehtmldom/files/ i suggest that you download it, then read the manual and follow the examples included with the download. Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167317 Share on other sites More sharing options...
nkoronka Posted January 30, 2011 Author Share Posted January 30, 2011 good idea, I'll get onto it. Cheers, Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167338 Share on other sites More sharing options...
QuickOldCar Posted January 30, 2011 Share Posted January 30, 2011 This is the only file need to include from the simplehtml dom folder you download include('simple_html_dom.php');//modify if in different location than your php script Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167363 Share on other sites More sharing options...
nkoronka Posted January 30, 2011 Author Share Posted January 30, 2011 Am I right in thinking that I include that line in my code? Would I also need to have the file in the same folder as the code I'm running or is it something included in my webhosts version of PHP? Thanks again for your help. Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167388 Share on other sites More sharing options...
QuickOldCar Posted January 30, 2011 Share Posted January 30, 2011 You download this as BlueSkyIS mentioned, you can even read the tutorials and examples. http://sourceforge.net/projects/simplehtmldom/files/ Upload the new simplehtmldom folder to your website. Every time you use simplehtml dom code you must include the file simple_html_dom.php once before you call any dom code. You can place simple_html_dom.php in the same folder as your script is, or can refer to it from the new simplehtmldom folder, that is up to you. Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167389 Share on other sites More sharing options...
QuickOldCar Posted January 30, 2011 Share Posted January 30, 2011 Here's the examples page http://simplehtmldom.sourceforge.net/ Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167393 Share on other sites More sharing options...
nkoronka Posted January 30, 2011 Author Share Posted January 30, 2011 Thanks, that's a great help! Quote Link to comment https://forums.phpfreaks.com/topic/226119-html-dom/#findComment-1167401 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.