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

Usage Example: FluentDOM:attr() Read an attribute value.

  1. <?php
  2. /**
  3. * Example file for function 'attr'
  4. *
  5. @version $Id: attr.php 322 2009-09-14 20:19:48Z subjective $
  6. @license http://www.opensource.org/licenses/mit-license.php The MIT License
  7. @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
  8. */
  9. header('Content-type: text/plain');
  10.  
  11. $xml = <<<XML
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <html:html xmlns:html='http://www.w3.org/1999/xhtml'>
  14.  <html:head>
  15.   <html:title>FluentDOM project page</html:title>
  16.  </html:head>
  17.  <html:body>
  18.   <html:p>
  19.    Always nice to visit
  20.    <html:a html:href='http://fluentdom.org'>here.</html:a>
  21.   </html:p>
  22.  </html:body>
  23. </html:html>
  24. XML;
  25.  
  26.  
  27. echo "Example for function 'attr' using XML namespaces:\n\n";
  28. require_once('../FluentDOM.php');
  29. $dom FluentDOM($xml);
  30. echo $dom
  31.   ->find('//html:a')
  32.   ->attr('html:href');
  33.  
  34. ?>

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