本文整理汇总了PHP中PEAR_XMLParser::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_XMLParser::getData方法的具体用法?PHP PEAR_XMLParser::getData怎么用?PHP PEAR_XMLParser::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_XMLParser
的用法示例。
在下文中一共展示了PEAR_XMLParser::getData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: parseXML
public function parseXML($content)
{
if (is_array($content)) {
return $content;
}
$parser = new PEAR_XMLParser();
$parser->parse($content);
return $parser->getData();
}
示例3:
/**
*/
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();
}
示例4: 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);
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例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;
}
}
示例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();
}
示例11: parse_package
/**
* creates a simplexml object
*/
public function parse_package()
{
$obj = new PEAR_XMLParser();
$obj->parse($this->package_xml);
$this->data = $obj->getData();
}