FluentDOM
[ class tree: FluentDOM ] [ index: FluentDOM ] [ all elements ]

Usage Example: FluentDOM::map()

  1. <?php
  2. /**
  3. *
  4. @version $Id: map.php 322 2009-09-14 20:19:48Z subjective $
  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.  
  10. $xml = <<<XML
  11. <html>
  12. <head></head>
  13. <body>
  14.   <p><b>Values: </b></p>
  15.   <form>
  16.     <input type="text" name="name" value="John"/>
  17.     <input type="text" name="password" value="password"/>
  18.     <input type="text" name="url" value="http://ejohn.org/"/>
  19.   </form>
  20. </body>
  21. </html>
  22. XML;
  23.  
  24. require_once('../FluentDOM.php');
  25. $dom FluentDOM($xml);
  26. echo $dom
  27.   ->find('//p')
  28.   ->append(
  29.     implode(
  30.       ', ',
  31.       $dom
  32.         ->find('//input')
  33.         ->map('getNodeAttribValue')
  34.     )
  35.   );
  36.  
  37. /**
  38. *
  39. *
  40. @param $node 
  41. @param $index 
  42. @return string | array
  43. */
  44. function getNodeAttribValue($node$index{
  45.   return FluentDOM($node)->attr('value');
  46. }
  47. ?>

Documentation generated on Sun, 26 Sep 2010 01:00:49 +0200 by phpDocumentor 1.4.3