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

Usage Example: FluentDOMLoaderStringJSON

  1. <?php
  2. /**
  3. * Sample how to use the JSON loader
  4. *
  5. * It loads the FluentDOM twitter timeline. This is only an example, Twitter provides XML, too.
  6. *
  7. @version $Id: jsonToXml.php 414 2010-03-26 17:27:03Z subjective $
  8. @package FluentDOM
  9. @subpackage examples
  10. */
  11.  
  12. require_once(dirname(__FILE__).'/../../FluentDOM.php');
  13. require_once(dirname(__FILE__).'/../../FluentDOM/Loader/StringJSON.php');
  14.  
  15. // get the loader object
  16. $jsonLoader new FluentDOMLoaderStringJSON();
  17. // activate type attributes
  18. $jsonLoader->typeAttributes TRUE;
  19. // get a FluentDOM
  20. $fd new FluentDOM();
  21. // inject the loader object
  22. $fd->setLoaders(array($jsonLoader));
  23.  
  24. $url 'http://twitter.com/status/user_timeline/FluentDOM.json?count=10';
  25. $json file_get_contents($url);
  26.  
  27. header('Content-type: text/xml');
  28. echo $fd->load($json)->formatOutput();
  29.  
  30. ?>

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