当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_XMLParser类代码示例

本文整理汇总了PHP中PEAR_XMLParser的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_XMLParser类的具体用法?PHP PEAR_XMLParser怎么用?PHP PEAR_XMLParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PEAR_XMLParser类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: retrieveData

 function retrieveData($url, $accept = false)
 {
     $cacheId = $this->getCacheId($url);
     $file = $this->downloadHttp($url, $this->ui, $this->getDownloadDir(), null, $cacheId, $accept);
     if (PEAR::isError($file)) {
         return $file;
     }
     if (!$file) {
         return $this->getCache($url);
     }
     $headers = $file[2];
     $lastmodified = $file[1];
     $content = implode('', file($file[0]));
     if (isset($headers['content-type'])) {
         switch ($headers['content-type']) {
             case 'text/xml':
                 $parser = new PEAR_XMLParser();
                 $parser->parse($file);
                 $content = $parser->getData();
             case 'text/html':
             default:
                 // use it as a string
         }
     } else {
         // assume XML
         $parser = new PEAR_XMLParser();
         $parser->parse($file);
         $content = $parser->getData();
     }
     $this->saveCache($url, $contents, $lastmodified);
     return $contents;
 }
开发者ID:alex-k,项目名称:velotur,代码行数:32,代码来源:REST.php

示例2: parseXML

 public function parseXML($content)
 {
     if (is_array($content)) {
         return $content;
     }
     $parser = new PEAR_XMLParser();
     $parser->parse($content);
     return $parser->getData();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:9,代码来源:opPearRest.class.php

示例3: PEAR_XMLParser

 /**
  */
 protected function &parse()
 {
     if (empty($this->raw)) {
         return false;
     }
     $parser = new PEAR_XMLParser();
     $this->valid = $parser->parse($this->raw);
     if (!$this->valid) {
         return false;
     }
     $this->data = $parser->getData();
 }
开发者ID:jldupont,项目名称:jldupont.com,代码行数:14,代码来源:Package.php

示例4: parse

 /** 
  * Parses the 'channel.xml' file
  */
 protected function parse(&$contents)
 {
     $parser = new PEAR_XMLParser();
     $result = $parser->parse($contents);
     if (!$result) {
         return false;
     }
     $this->data = $parser->getData();
     if (isset($this->data['name'])) {
         $this->setVar('name', $this->data['name']);
         return $this->data['name'];
     }
     return null;
 }
开发者ID:jldupont,项目名称:jldupont.com,代码行数:17,代码来源:Channel.php

示例5: c_cache_xml

function c_cache_xml($var, $f_try = 0)
{
    global $system;
    extract($var, EXTR_OVERWRITE);
    $XML_DATA = array();
    $xml_info = array();
    $system->cache->open("./Cache/XML", NULL);
    $xml_info = $system->cache->read("xml-stats");
    if (!is_array($system->sl) and !isset($system->sl[$system->as])) {
        $v = $system->sl[0]['xml'];
    } else {
        $v = $system->sl[$system->as]['xml'];
    }
    if (!empty($xml_info)) {
        $xml_info = unserialize($xml_info);
        if ($xml_info["mtime"] <= 1 or $xml_time != $xml_info["mtime"]) {
            if ($xml_time != -2) {
                $system->cache->destroy("xml-stats");
                $xml_info = "";
            }
        }
        if (is_array($xml_info)) {
            //extract($xml_info,EXTR_OVERWRITE);
            $XML_DATA = $xml_info['data'];
            unset($xml_info);
            unset($mtime);
        }
    } else {
        require_once "./inc/XMLParser.php";
        $p = new PEAR_XMLParser();
        if ($p->parse(implode("", file($v)), $v, 0)) {
            $data = $p->getData();
            $system->cache->write("xml-stats", serialize(array("data" => $data, "mtime" => $xml_time)));
            $XML_DATA = $data;
        }
    }
    $system->xml = $XML_DATA;
    if ((!is_array($system->xml) or !isset($system->xml['instances']) or !isset($system->xml['instances']['instance']) or !isset($system->xml['status']) or !is_array($system->xml['status']) or !is_array($system->xml['instances']['instance'])) and $f_try < 5) {
        sleep(0.1);
        $a = c_cache_xml($var, $f_try + 1);
    }
    return array("xml_data" => $XML_DATA);
}
开发者ID:googlecode-mirror,项目名称:ascent-phpstats,代码行数:43,代码来源:cache.inc.php

示例6: registerRoles

 /**
  * Scan through the Command directory looking for classes
  * and see what commands they implement.
  * @param string which directory to look for classes, defaults to
  *               the Installer/Roles subdirectory of
  *               the directory from where this file (__FILE__) is
  *               included.
  *
  * @return bool TRUE on success, a PEAR error on failure
  * @access public
  * @static
  */
 function registerRoles($dir = null)
 {
     $GLOBALS['_PEAR_INSTALLER_ROLES'] = array();
     $parser = new PEAR_XMLParser();
     if ($dir === null) {
         $dir = dirname(__FILE__) . '/Role';
     }
     if (!file_exists($dir) || !is_dir($dir)) {
         return PEAR::raiseError("registerRoles: opendir({$dir}) failed");
     }
     $dp = @opendir($dir);
     if (empty($dp)) {
         return PEAR::raiseError("registerRoles: opendir({$dir}) failed");
     }
     while ($entry = readdir($dp)) {
         if ($entry[0] == '.' || substr($entry, -4) != '.xml') {
             continue;
         }
         $class = "PEAR_Installer_Role_" . substr($entry, 0, -4);
         // List of roles
         if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
             $file = "{$dir}/{$entry}";
             $parser->parse(file_get_contents($file));
             $data = $parser->getData();
             if (!is_array($data['releasetypes'])) {
                 $data['releasetypes'] = array($data['releasetypes']);
             }
             $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data;
         }
     }
     closedir($dp);
     ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
     PEAR_Installer_Role::getBaseinstallRoles(true);
     PEAR_Installer_Role::getInstallableRoles(true);
     PEAR_Installer_Role::getPhpRoles(true);
     PEAR_Installer_Role::getValidRoles('****', true);
     return true;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:50,代码来源:Role.php

示例7: registerCommands

 /**
  * Scan through the Command directory looking for classes
  * and see what commands they implement.
  *
  * @param bool   (optional) if FALSE (default), the new list of
  *               commands should replace the current one.  If TRUE,
  *               new entries will be merged with old.
  *
  * @param string (optional) where (what directory) to look for
  *               classes, defaults to the Command subdirectory of
  *               the directory from where this file (__FILE__) is
  *               included.
  *
  * @return bool TRUE on success, a PEAR error on failure
  *
  * @access public
  * @static
  */
 function registerCommands($merge = false, $dir = null)
 {
     $parser = new PEAR_XMLParser();
     if ($dir === null) {
         $dir = dirname(__FILE__) . '/Command';
     }
     $dp = @opendir($dir);
     if (empty($dp)) {
         return PEAR::raiseError("registerCommands: opendir({$dir}) failed");
     }
     if (!$merge) {
         $GLOBALS['_PEAR_Command_commandlist'] = array();
     }
     while ($entry = readdir($dp)) {
         if ($entry[0] == '.' || substr($entry, -4) != '.xml') {
             continue;
         }
         $class = "PEAR_Command_" . substr($entry, 0, -4);
         $file = "{$dir}/{$entry}";
         $parser->parse(file_get_contents($file));
         $implements = $parser->getData();
         // List of commands
         if (empty($GLOBALS['_PEAR_Command_objects'][$class])) {
             $GLOBALS['_PEAR_Command_objects'][$class] = "{$dir}/" . substr($entry, 0, -4) . '.php';
         }
         foreach ($implements as $command => $desc) {
             if ($command == 'attribs') {
                 continue;
             }
             if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
                 return PEAR::raiseError('Command "' . $command . '" already registered in ' . 'class "' . $GLOBALS['_PEAR_Command_commandlist'][$command] . '"');
             }
             $GLOBALS['_PEAR_Command_commandlist'][$command] = $class;
             $GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc['summary'];
             if (isset($desc['shortcut'])) {
                 $shortcut = $desc['shortcut'];
                 if (isset($GLOBALS['_PEAR_Command_shortcuts'][$shortcut])) {
                     return PEAR::raiseError('Command shortcut "' . $shortcut . '" already ' . 'registered to command "' . $command . '" in class "' . $GLOBALS['_PEAR_Command_commandlist'][$command] . '"');
                 }
                 $GLOBALS['_PEAR_Command_shortcuts'][$shortcut] = $command;
             }
             if (isset($desc['options']) && $desc['options']) {
                 foreach ($desc['options'] as $oname => $option) {
                     if (isset($option['shortopt']) && strlen($option['shortopt']) > 1) {
                         return PEAR::raiseError('Option "' . $oname . '" short option "' . $option['shortopt'] . '" must be ' . 'only 1 character in Command "' . $command . '" in class "' . $class . '"');
                     }
                 }
             }
         }
     }
     ksort($GLOBALS['_PEAR_Command_shortcuts']);
     ksort($GLOBALS['_PEAR_Command_commandlist']);
     @closedir($dp);
     return true;
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:73,代码来源:Command.php

示例8: retrieveData

 /**
  * Retrieve a remote REST resource
  * @param string full URL to this resource
  * @param array|false contents of the accept-encoding header
  * @param boolean     if true, xml will be returned as a string, otherwise, xml will be
  *                    parsed using PEAR_XMLParser
  * @return string|array
  */
 function retrieveData($url, $accept = false, $forcestring = false)
 {
     $cacheId = $this->getCacheId($url);
     if ($ret = $this->useLocalCache($url, $cacheId)) {
         return $ret;
     }
     if (!isset($this->_options['offline'])) {
         $trieddownload = true;
         $file = $this->downloadHttp($url, $cacheId ? $cacheId['lastChange'] : false, $accept);
     } else {
         $trieddownload = false;
         $file = false;
     }
     if (PEAR::isError($file)) {
         if ($file->getCode() == -9276) {
             $trieddownload = false;
             $file = false;
             // use local copy if available on socket connect error
         } else {
             return $file;
         }
     }
     if (!$file) {
         $ret = $this->getCache($url);
         if (!PEAR::isError($ret) && $trieddownload) {
             // reset the age of the cache if the server says it was unmodified
             $this->saveCache($url, $ret, null, true, $cacheId);
         }
         return $ret;
     }
     if (is_array($file)) {
         $headers = $file[2];
         $lastmodified = $file[1];
         $content = $file[0];
     } else {
         $content = $file;
         $lastmodified = false;
         $headers = array();
     }
     if ($forcestring) {
         $this->saveCache($url, $content, $lastmodified, false, $cacheId);
         return $content;
     }
     if (isset($headers['content-type'])) {
         switch ($headers['content-type']) {
             case 'text/xml':
             case 'application/xml':
                 $parser = new PEAR_XMLParser();
                 PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                 $err = $parser->parse($content);
                 PEAR::popErrorHandling();
                 if (PEAR::isError($err)) {
                     return PEAR::raiseError('Invalid xml downloaded from "' . $url . '": ' . $err->getMessage());
                 }
                 $content = $parser->getData();
             case 'text/html':
             default:
                 // use it as a string
         }
     } else {
         // assume XML
         $parser = new PEAR_XMLParser();
         $parser->parse($content);
         $content = $parser->getData();
     }
     $this->saveCache($url, $content, $lastmodified, false, $cacheId);
     return $content;
 }
开发者ID:kractos26,项目名称:orfeo,代码行数:76,代码来源:REST.php

示例9: fromXmlString

 /**
  * @param string contents of package.xml file
  * @return bool success of parsing
  */
 function fromXmlString($data)
 {
     if (preg_match('/<channel\\s+version="([0-9]+\\.[0-9]+)"/', $data, $channelversion)) {
         if (!in_array($channelversion[1], $this->_supportedVersions)) {
             $this->_stack->push(PEAR_CHANNELFILE_ERROR_INVALID_VERSION, 'error', array('version' => $channelversion[1]));
             return false;
         }
         $parser = new PEAR_XMLParser();
         $result = $parser->parse($data);
         if ($result !== true) {
             if ($result->getCode() == 1) {
                 $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_XML_EXT, 'error', array('error' => $result->getMessage()));
             } else {
                 $this->_stack->push(PEAR_CHANNELFILE_ERROR_CANT_MAKE_PARSER, 'error');
             }
             return false;
         }
         $this->_channelInfo = $parser->getData();
         return true;
     } else {
         $this->_stack->push(PEAR_CHANNELFILE_ERROR_NO_VERSION, 'error', array('xml' => $data));
         return false;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:28,代码来源:ChannelFile.php

示例10: parse

 /**
  * Parses an XML file.
  */
 protected function parse(&$contents)
 {
     $parser = new PEAR_XMLParser();
     $result = $parser->parse($contents);
     if (!$result) {
         return false;
     }
     return $parser->getData();
 }
开发者ID:jldupont,项目名称:jldupont.com,代码行数:12,代码来源:ChannelCategories.php

示例11: parse_package

 /**
  * creates a simplexml object
  */
 public function parse_package()
 {
     $obj = new PEAR_XMLParser();
     $obj->parse($this->package_xml);
     $this->data = $obj->getData();
 }
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:9,代码来源:package_extractor.php

示例12: parse

 function parse($data, $file, $archive = false)
 {
     if (PEAR::isError($err = parent::parse($data, $file))) {
         return $err;
     }
     $ret = new PEAR_PackageFile_v2();
     $ret->setConfig($this->_config);
     if (isset($this->_logger)) {
         $ret->setLogger($this->_logger);
     }
     $ret->fromArray($this->_unserializedData);
     $ret->setPackagefile($file, $archive);
     return $ret;
 }
开发者ID:alex-k,项目名称:velotur,代码行数:14,代码来源:v2.php

示例13: parse

 function parse($data, $file)
 {
     if (PEAR::isError($err = parent::parse($data, $file))) {
         return $err;
     }
     $ret = new PEAR_ChannelFile();
     $ret->setConfig($this->_config);
     if (isset($this->_logger)) {
         $ret->setLogger($this->_logger);
     }
     $ret->fromArray($this->_unserializedData);
     // make sure the filelist is in the easy to read format needed
     $ret->flattenFilelist();
     $ret->setPackagefile($file, $archive);
     return $ret;
 }
开发者ID:orcoliver,项目名称:oneye,代码行数:16,代码来源:Parser.php

示例14: parse

 /**
  * @param string
  * @param string file name of the package.xml
  * @param string|false name of the archive this package.xml came from, if any
  * @param string class name to instantiate and return.  This must be PEAR_PackageFile_v2 or
  *               a subclass
  * @return PEAR_PackageFile_v2
  */
 function parse($data, $file, $archive = false, $class = 'PEAR_PackageFile_v2')
 {
     $test = $this->preProcessStupidSaxon($data);
     if (PEAR::isError($err = parent::parse($data, $file))) {
         return $err;
     }
     $ret = new $class();
     if ($test != $data) {
         $ret->_stack->push('_warningNonIsoChars', 'warning', array(), 'Non-ISO-8859-1 character detected, validation may fail');
     }
     $ret->setConfig($this->_config);
     if (isset($this->_logger)) {
         $ret->setLogger($this->_logger);
     }
     $ret->fromArray($this->_unserializedData);
     $ret->setPackagefile($file, $archive);
     return $ret;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:26,代码来源:v2.php


注:本文中的PEAR_XMLParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。