f32073c4dc46b5ba06ddad56fdecf490d6c57759.svn-base 577 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. include_once('../simple_html_dom.php');
  3. // 1. Write a function with parameter "$element"
  4. function my_callback($element) {
  5. if ($element->tag=='input')
  6. $element->outertext = 'input';
  7. if ($element->tag=='img')
  8. $element->outertext = 'img';
  9. if ($element->tag=='a')
  10. $element->outertext = 'a';
  11. }
  12. // 2. create HTML Dom
  13. $html = file_get_html('http://www.google.com/');
  14. // 3. Register the callback function with it's function name
  15. $html->set_callback('my_callback');
  16. // 4. Callback function will be invoked while dumping
  17. echo $html;
  18. ?>