boneXXX Posted October 13, 2008 Share Posted October 13, 2008 hi all, I am trying to figure out how simple DOM parser works. If someone can explain these example code, I would really appreciate it. <?php include_once('./simple_html_dom.php'); // 1. Write a function with parameter "$element" function my_callback($element) { if ($element->tag=='h1') $element->innertext = 'h1'; if ($element->tag=='h1') $element->outertext = 'h1'; if ($element->tag=='img') $element->outertext = 'img'; if ($element->tag=='a') $element->outertext = 'a'; } // 2. Create DOM from URL $html = file_get_html('http://www.example.com/'); // 3. Register the callback function with it's function name $html->set_callback('my_callback'); // 4. Callback function will be invoked while dumping echo $html; ?> Link to comment https://forums.phpfreaks.com/topic/128134-question-about-simple-dom-parser/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.