PageRenderTime 41ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/prev.php

http://github.com/ThomasWeinert/FluentDOM
PHP | 39 lines | 29 code | 4 blank | 6 comment | 0 complexity | bc0bf42481f843b0d1fc45d551dedb12 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * @version $Id$
  5. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  6. * @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
  7. */
  8. header('Content-type: text/plain');
  9. $xml = <<<XML
  10. <html>
  11. <head></head>
  12. <body>
  13. <div><span>has child</span></div>
  14. <div id="start"></div>
  15. <div></div>
  16. <div><span>has child</span></div>
  17. <div class="here"><span>has child</span></div>
  18. <div><span>has child</span></div>
  19. <div class="here"></div>
  20. <div></div>
  21. <p><button>Go to Prev</button></p>
  22. </body>
  23. </html>
  24. XML;
  25. require_once('../src/FluentDOM.php');
  26. echo FluentDOM($xml)
  27. ->find('//div[@id = "start"]')
  28. ->prev()
  29. ->addClass('before');
  30. echo "\n\n";
  31. echo FluentDOM($xml)
  32. ->find('//div[@class= "here"]')
  33. ->prev('.//span')
  34. ->addClass('nextTest');
  35. ?>