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

Usage Example: FluentDOM::parent()

  1. <?php
  2. /**
  3. *
  4. @version $Id: parent.php 429 2010-03-29 08:05:32Z 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.   <div>div,
  15.     <span>span, </span>
  16.     <b>b </b>
  17.   </div>
  18.   <p>p,
  19.     <span>span,
  20.       <em>em </em>
  21.     </span>
  22.   </p>
  23.   <div>div,
  24.     <strong>strong,
  25.       <span>span, </span>
  26.       <em>em,
  27.         <b>b, </b>
  28.       </em>
  29.     </strong>
  30.     <b>b </b>
  31.   </div>
  32. </body>
  33. </html>
  34. XML;
  35.  
  36. require_once('../FluentDOM.php');
  37.  
  38. echo FluentDOM($xml)
  39.   ->find('//body//*')
  40.   ->each('callback');
  41.  
  42.  
  43. function callback($node{
  44.   $fluentNode FluentDOM($node);
  45.   $fluentNode->prepend(
  46.     $fluentNode->document->createTextNode(
  47.       $fluentNode->parent()->item(0)->tagName.' > '
  48.     )
  49.   );
  50. }
  51. ?>

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