/examples/prev.php
PHP | 39 lines | 29 code | 4 blank | 6 comment | 0 complexity | bc0bf42481f843b0d1fc45d551dedb12 MD5 | raw file
- <?php
- /**
- *
- * @version $Id$
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- * @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
- */
- header('Content-type: text/plain');
- $xml = <<<XML
- <html>
- <head></head>
- <body>
- <div><span>has child</span></div>
- <div id="start"></div>
- <div></div>
- <div><span>has child</span></div>
- <div class="here"><span>has child</span></div>
- <div><span>has child</span></div>
- <div class="here"></div>
- <div></div>
- <p><button>Go to Prev</button></p>
- </body>
- </html>
- XML;
- require_once('../src/FluentDOM.php');
- echo FluentDOM($xml)
- ->find('//div[@id = "start"]')
- ->prev()
- ->addClass('before');
- echo "\n\n";
- echo FluentDOM($xml)
- ->find('//div[@class= "here"]')
- ->prev('.//span')
- ->addClass('nextTest');
- ?>