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

Source for file xml.php

Documentation is available at xml.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * API for Digg's web services
  7.  *
  8.  * PHP version 5.1.0+
  9.  *
  10.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  11.  * that is available through the world-wide-web at the following URI:
  12.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  13.  * the PHP License and are unable to obtain it through the web, please
  14.  * send a note to license@php.net so we can mail you a copy immediately.
  15.  *
  16.  * @category    Services
  17.  * @package     Services_Digg
  18.  * @author      Joe Stump <joe@joestump.net>
  19.  * @copyright   1997-2007 The PHP Group
  20.  * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
  21.  * @version     CVS: $Id:$
  22.  * @link        http://pear.php.net/package/Services_Digg
  23.  */
  24.  
  25. require_once 'Services/Digg/Response/Common.php';
  26.  
  27. /**
  28.  * XML response parser
  29.  *
  30.  * XML responses are, technically, supported by this package, but only bug
  31.  * fixes will be handled. Consider this deprecated and unsupported by the
  32.  * developers.
  33.  *
  34.  * @author      Joe Stump <joe@joestump.net>
  35.  * @category    Services
  36.  * @package     Services_Digg
  37.  * @deprecated
  38.  */
  39. {
  40.     /**
  41.      * Parse the response
  42.      *
  43.      * @access      public
  44.      * @return      object      Instance of SimpleXMLElement
  45.      * @throws      Services_Digg_Exception
  46.      */
  47.     public function parse()
  48.     {
  49.         if (!function_exists('simplexml_load_string')) {
  50.             throw new Services_Digg_Response_Exception('simplexml_load_string() not found');
  51.         }
  52.  
  53.         $xml @simplexml_load_string($this->response);
  54.         if (!$xml instanceof SimpleXmlElement{
  55.             throw new Services_Digg_Response_Exception('Could not parse XML response');
  56.         }
  57.  
  58.         if ((isset($xml['code']&& is_numeric($xml['code'])) && 
  59.             (isset($xml['message']&& strlen($xml['message']))) {
  60.             throw new Services_Digg_Response_Exception((string)$xml['message'](int)$xml['code']);
  61.         }
  62.  
  63.         return $xml;
  64.     }
  65. }
  66.  
  67. ?>

Documentation generated on Tue, 04 Dec 2007 15:00:14 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.