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

Usage Example: FluentDOM::append()

  1. <?php
  2. /**
  3. *
  4. @version $Id: append.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>I would like to say: </p>
  15.   <items>
  16.     <group>
  17.       <item index="0">text1</item>
  18.       <item index="1">text2</item>
  19.       <item index="2">text3</item>
  20.     </group>
  21.     <html>
  22.       <div class="test1 test2"><b>class testing</b></div>
  23.       <div class="test2"><b>class testing</b></div>
  24.     </html>
  25.   </items>
  26. </body>
  27. </html>
  28. XML;
  29.  
  30. require_once('../FluentDOM.php');
  31. echo FluentDOM($xml)
  32.   ->find('//p')
  33.   ->append('<strong>Hello</strong>')
  34.   ->formatOutput();
  35.  
  36. echo "\n\n";
  37.  
  38. $dom FluentDOM($xml);
  39. $items $dom->find('//group/item');
  40. echo $dom
  41.   ->find('//html/div')
  42.   ->append($items)
  43.   ->formatOutput();
  44.  
  45. ?>

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