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


PHP Xml类代码示例

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


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

示例1: xml_unserialize

 public static function xml_unserialize(&$xml, $isnormal = FALSE)
 {
     $xml_parser = new Xml($isnormal);
     $data = $xml_parser->parse($xml);
     $xml_parser->destruct();
     return $data;
 }
开发者ID:hustshenl,项目名称:yii2-ucenter,代码行数:7,代码来源:Xml.php

示例2: __construct

 public function __construct()
 {
     global $dbconfig;
     /*
      * ANTIGO METODO ANTES DO XML!!!
      * PEGAVA DIRETO DO CONFIGURATIONS.INC.PHP 
      * if(!isset(self::$conexao))
     {
     	$dsn = "{$dbconfig['driver']}:host={$dbconfig['server']};dbname={$dbconfig['database']}";
     }
     
     try
     {
     		self::$conexao = new PDO($dsn,	
     									 $dbconfig['user'],
     									 $dbconfig['password'],
     									 $dbconfig['options']);
     }
     */
     $xml = new Xml(_XML_DB_);
     $xml->setConstant();
     if (!isset(self::$conexao)) {
         $dsn = $xml->dsn();
         try {
             self::$conexao = new PDO($dsn, USER, PASSWORD);
         } catch (PDOException $e) {
             $erro = 'Erro: ' . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
             error_log(date('d-m-Y H:i:s') . '-' . $erro, 3, LOG_FILE);
             die($erro);
         }
     }
 }
开发者ID:egbertomonteiro,项目名称:Livraria,代码行数:32,代码来源:Tabela.class.php

示例3: plugin_dst_xml_read

function plugin_dst_xml_read()
{
    // Perform the repository lookup and xml creation --- start
    $localFile = 'plugins/dst/countries.xml';
    $result = array('body' => file_get_contents($localFile));
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $dst_array = array();
        foreach ($xml as $file) {
            $dst_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $dst_array = $xml->parse($result);
        $dst_array = array_shift($dst_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $dst_array;
}
开发者ID:phill104,项目名称:branches,代码行数:25,代码来源:functions.inc.php

示例4: import

 /**
  * undocumented function
  *
  * @param string $file 
  * @return void
  * @access public
  */
 function import($file)
 {
     $source = file_get_contents($file);
     $xml = new Xml($source);
     $result = $xml->toArray();
     $result = $result['Xmlarchive']['Fileset']['File'];
     if (empty($result)) {
         return false;
     }
     $count = 0;
     foreach ($result as $smiley) {
         $name = $smiley['filename'];
         $content = $smiley['content'];
         $content = preg_replace('/\\s/', '', $content);
         $content = base64_decode($content);
         $filePath = SMILEY_PATH . $name;
         if (file_exists($filePath)) {
             continue;
         }
         $this->create(array('code' => ':' . r('.gif', '', $name) . ':', 'filename' => $name));
         $this->save();
         $f = fopen($filePath, 'w+');
         fwrite($f, $content);
         fclose($f);
         $count++;
     }
     return $count;
 }
开发者ID:stripthis,项目名称:donate,代码行数:35,代码来源:smiley.php

示例5: get

 public function get(&$accessToken, &$oauthConsumer)
 {
     // we need the GUID of the user for Yahoo
     $guid = $oauthConsumer->get($accessToken->key, $accessToken->secret, 'http://social.yahooapis.com/v1/me/guid');
     // Yahoo returns XML, so break it apart and make it an array
     $xml = new Xml($guid);
     // Or you can convert simply by calling toArray();
     $guid = $xml->toArray();
     // get them contacts
     $contacts = $oauthConsumer->get($accessToken->key, $accessToken->secret, 'http://social.yahooapis.com/v1/user/' . $guid['Guid']['value'] . '/contacts', array('count' => 'max', 'format' => 'xml'));
     // return array
     $c = array();
     // counter
     $i = 0;
     // new xml object
     $xml = new Xml($contacts);
     $contacts = $xml->toArray();
     // let's break apart Yahoo's contact format and make it our own, extracting what we want
     foreach ($contacts['Contacts']['Contact'] as $contact) {
         foreach ($contact['Fields'] as $field) {
             if ($field['type'] == 'email') {
                 $c[$i]['Contact']['email'][] = $field['value'];
             }
             if ($field['type'] == 'name' && isset($c[$i]['Contact']['email'])) {
                 $firstName = isset($field['Value']['givenName']) ? $field['Value']['givenName'] : '';
                 $lastName = isset($field['Value']['familyName']) ? $field['Value']['familyName'] : '';
                 $c[$i]['Contact']['fullName'] = $firstName . ' ' . $lastName;
             }
         }
         $i++;
     }
     return $c;
 }
开发者ID:RobertWHurst,项目名称:Telame,代码行数:33,代码来源:yahoo_consumer.php

示例6: isUpToDate

 /**
  * Verifica se os menus do banco estão atualizados com os do arquivo
  * @param $aDados- array de menus do banco
  * @return boolean
  */
 public function isUpToDate($aDados)
 {
     $aDados = Set::combine($aDados, "/Menu/id", "/Menu");
     App::import("Xml");
     App::import("Folder");
     App::import("File");
     $sCaminhosArquivos = Configure::read("Cms.CheckPoint.menus");
     $oFolder = new Folder($sCaminhosArquivos);
     $aConteudo = $oFolder->read();
     $aArquivos = Set::sort($aConteudo[1], "{n}", "desc");
     if (empty($aArquivos)) {
         return false;
     }
     $oFile = new File($sCaminhosArquivos . $aArquivos[0]);
     $oXml = new Xml($oFile->read());
     $aAntigo = $oXml->toArray();
     foreach ($aDados as &$aMenu) {
         $aMenu['Menu']['content'] = str_replace("\r\n", " ", $aMenu['Menu']['content']);
     }
     if (isset($aAntigo["menus"])) {
         $aAntigo["Menus"] = $aAntigo["menus"];
         unset($aAntigo["menus"]);
     }
     if (isset($aAntigo["Menus"])) {
         $aAntigo = Set::combine($aAntigo["Menus"], "/Menu/id", "/Menu");
         $aRetorno = Set::diff($aDados, $aAntigo);
     }
     return empty($aRetorno);
 }
开发者ID:niltonfelipe,项目名称:e-cidade_transparencia,代码行数:34,代码来源:check_point.php

示例7: index

 public function index()
 {
     $this->load->helper('directory');
     $map = directory_map(APPPATH . DS . 'modules', 1);
     // get all modules
     $module = array();
     if (count($map) > 0) {
         for ($i = 0; $i < count($map); $i++) {
             $file = APPPATH . DS . 'modules' . DS . $map[$i] . DS . $map[$i] . '.xml';
             if (file_exists($file)) {
                 $module[] = $map[$i];
             }
         }
     }
     // load modules info
     $this->load->library('xml');
     $xml = new Xml();
     $modules = array();
     $j = 0;
     for ($i = 0; $i < count($module); $i++) {
         $file = APPPATH . DS . 'modules' . DS . $module[$i] . DS . $module[$i] . '.xml';
         $data = $xml->parse($file);
         if (isset($data['name']) && $data['name'] != '' && isset($data['description']) && $data['description'] != '') {
             $modules[$j] = new stdclass();
             $modules[$j]->name = $module[$i];
             $modules[$j]->title = $data['name'];
             $modules[$j]->description = $data['description'];
             $modules[$j]->thumb = 'application/modules/' . $module[$i] . '/thumb.png';
             $j++;
         }
     }
     // get page layout
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     $pages = array();
     if (count($layouts)) {
         $i = 0;
         //echo '<pre>'; print_r($layouts['group']); exit;
         foreach ($layouts['group'] as $group) {
             if (empty($group['@attributes']['description'])) {
                 continue;
             }
             $pages[$i] = new stdClass();
             $pages[$i]->name = $group['@attributes']['name'];
             $pages[$i]->description = $group['@attributes']['description'];
             if (empty($group['@attributes']['icon']) || $group['@attributes']['icon'] == '') {
                 $pages[$i]->icon = base_url('assets/images/system/home.png');
             } else {
                 $pages[$i]->icon = base_url('assets/images/system/' . $group['@attributes']['icon']);
             }
             $i++;
         }
     }
     $this->data['pages'] = $pages;
     $this->data['modules'] = $modules;
     $this->load->view('admin/module/index', $this->data);
 }
开发者ID:Nnamso,项目名称:tbox,代码行数:59,代码来源:module.php

示例8: insert_node

 function insert_node($newXml)
 {
     if ($newXml) {
         $newNode = new Xml($newXml);
         $insertNode = $newNode->documentElement();
         $this->xml->documentElement->appendChild($this->xml->importNode($insertNode, true));
     }
 }
开发者ID:nibble-arts,项目名称:feedback,代码行数:8,代码来源:xml.php

示例9: test_parse_returnsTrue_ifOutputIsValidXml

 /**
  * parse() should return true if output if well-formed xml
  */
 public function test_parse_returnsTrue_ifOutputIsValidXml()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<foo>' . '<bar>' . 'baz' . '</bar>' . '<bar>' . 'qux' . '</bar>' . '</foo>';
     $data = ['bar' => ['baz', 'qux']];
     $response = new Xml();
     $this->assertTrue($response->parse($xml));
     $this->assertEquals($data, $response->getData());
     return;
 }
开发者ID:jstewmc,项目名称:api,代码行数:12,代码来源:XmlTest.php

示例10: parse

 /**
  * parse xml
  * 2010-02-07 ms
  */
 function parse($file)
 {
     App::import('Core', 'Xml');
     $xml = new Xml($file);
     $res = $xml->toArray();
     if (!empty($res['Xss']['Attack'])) {
         return (array) $res['Xss']['Attack'];
     }
     return array();
 }
开发者ID:robksawyer,项目名称:tools,代码行数:14,代码来源:security_lib.php

示例11: paginate

 /**
  * paginate
  *
  * @param  mixed $conditions
  * @param  mixed $fields
  * @param  mixed $order
  * @param  integer $limit
  * @param  integer $page
  * @param  integer $recursive
  * @param  array $extract
  * @return array
  */
 public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra)
 {
     $HttpSocket = new HttpSocket();
     $query = array('q' => Set::extract('q', $conditions), 'page' => $page, 'rpp' => $limit, 'lang' => Set::extract('lang', $conditions));
     $ret = $HttpSocket->get(self::API_SEARCH, $query);
     if ($ret) {
         $Xml = new Xml($ret);
         return $Xml->toArray();
     }
     return array();
 }
开发者ID:shin1x1,项目名称:findTwitter,代码行数:23,代码来源:twitter.php

示例12: __tickets

 /**
  * undocumented function
  *
  * @return void
  */
 function __tickets()
 {
     $this->out('This may take a while...');
     $project = @$this->args[1];
     $fork = null;
     if ($this->Project->initialize(compact('project', 'fork')) === false || $this->Project->current['url'] !== $project) {
         $this->err('Invalid project');
         return 1;
     }
     $path = $this->args[2];
     $ext = array_pop(explode('.', $path));
     if ($ext == 'xml') {
         App::import('Xml');
         $Xml = new Xml($path);
         $rows = array();
         $this->out('Importing Data...');
         foreach ($Xml->toArray() as $key => $data) {
             foreach ($data['Records']['Row'] as $columns) {
                 $new = array();
                 foreach ($columns['Column'] as $column) {
                     if ($column['name'] == 'created' || $column['name'] == 'modified') {
                         $column['value'] = date('Y-m-d H:i:s', $column['value']);
                     }
                     $new[$column['name']] = $column['value'];
                 }
                 $new['project_id'] = $this->Project->id;
                 $this->Ticket->create($new);
                 if ($this->Ticket->save()) {
                     $this->out('Ticket ' . $new['number'] . ' : ' . $new['title'] . ' migrated');
                     sleep(1);
                 }
             }
         }
         return 0;
     }
     $File = new File($path);
     $data = explode("\n", $File->read());
     $fields = explode(',', array_shift($data));
     foreach ($fields as $key => $field) {
         $fields[$key] = str_replace('"', '', $field);
     }
     pr($fields);
     $result = array();
     foreach ($data as $line) {
         $values = explode(',', $line);
         foreach ($values as $key => $value) {
             $field = str_replace('"', '', $fields[$key]);
             $result[$field] = str_replace('"', '', $value);
         }
     }
     pr($result);
 }
开发者ID:Theaxiom,项目名称:chaw-source,代码行数:57,代码来源:trac.php

示例13: valorFrete

 function valorFrete(&$model, $servico, $cepOrigem, $cepDestino, $peso, $maoPropria = false, $valorDeclarado = 0.0, $avisoRecebimento = false)
 {
     // Validação dos parâmetros
     $tipos = array(CORREIOS_SEDEX, CORREIOS_SEDEX_A_COBRAR, CORREIOS_SEDEX_10, CORREIOS_SEDEX_HOJE, CORREIOS_ENCOMENDA_NORMAL);
     if (!in_array($servico, $tipos)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     $Validacao = new ValidacaoBehavior();
     if (!$Validacao->_cep($cepOrigem, '-') || !$Validacao->_cep($cepDestino, '-')) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if (!is_numeric($peso) || !is_numeric($valorDeclarado)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($peso > 30.0) {
         return ERRO_CORREIOS_EXCESSO_PESO;
     } elseif ($peso < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($valorDeclarado < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     // Ajustes nos parâmetros
     if ($maoPropria) {
         $maoPropria = 'S';
     } else {
         $maoPropria = 'N';
     }
     if ($avisoRecebimento) {
         $avisoRecebimento = 'S';
     } else {
         $avisoRecebimento = 'N';
     }
     // Requisição
     $HttpSocket = new HttpSocket();
     $uri = array('scheme' => 'http', 'host' => 'www.correios.com.br', 'port' => 80, 'path' => '/encomendas/precos/calculo.cfm', 'query' => array('resposta' => 'xml', 'servico' => $servico, 'cepOrigem' => $cepOrigem, 'cepDestino' => $cepDestino, 'peso' => $peso, 'MaoPropria' => $maoPropria, 'valorDeclarado' => $valorDeclarado, 'avisoRecebimento' => $avisoRecebimento));
     $retornoCorreios = trim($HttpSocket->get($uri));
     if ($HttpSocket->response['status']['code'] != 200) {
         return ERRO_CORREIOS_FALHA_COMUNICACAO;
     }
     $Xml = new Xml($retornoCorreios);
     $infoCorreios = $Xml->toArray();
     if (!isset($infoCorreios['CalculoPrecos']['DadosPostais'])) {
         return ERRO_CORREIOS_CONTEUDO_INVALIDO;
     }
     extract($infoCorreios['CalculoPrecos']['DadosPostais']);
     return array('ufOrigem' => $uf_origem, 'ufDestino' => $uf_destino, 'capitalOrigem' => $local_origem == 'Capital', 'capitalDestino' => $local_destino == 'Capital', 'valorMaoPropria' => $mao_propria, 'valorTarifaValorDeclarado' => $tarifa_valor_declarado, 'valorFrete' => $preco_postal - $tarifa_valor_declarado - $mao_propria, 'valorTotal' => $preco_postal);
 }
开发者ID:edubress,项目名称:cake_ptbr,代码行数:48,代码来源:correios.php

示例14: restore

 /**
  * Função para restauração
  */
 public function restore()
 {
     $sDiretorio = Configure::read('Cms.CheckPoint.menus');
     if (!is_dir($sDiretorio)) {
         $this->Session->setFlash("Diretório das restaurações não configurado.", 'default', array('class' => "alert alert-error"));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     }
     /**
      * Faz a restauração
      */
     if (!empty($this->data)) {
         $this->loadModel('Cms.Menu');
         App::import('Xml');
         $oSnapXml = new Xml($sDiretorio . $this->data['CheckPoint']['snapshot']);
         $aSnap = $oSnapXml->toArray();
         $aRestore = !empty($aSnap['Menus']) ? $aSnap['Menus']['Menu'] : array();
         /**
          * Verifica se possui apenas um item de menu no xml e trata de uma forma diferente.
          * -- Função de XML do Cake salva de formas diferentes o XML quando possui apenas um item.
          */
         if (!empty($aRestore) && !isset($aRestore[0])) {
             $aRestore = array($aRestore);
         }
         $this->CheckPoint->generate();
         if ($this->Menu->restauraBackup($aRestore)) {
             $this->Session->setFlash("Restaurado com sucesso.", 'default', array('class' => "alert alert-success"));
         } else {
             $this->Session->setFlash("Erro ao restaurar.", 'default', array('class' => "alert alert-error"));
         }
     }
     /**
      * Pega os snapshots salvos e invverte a ordem para exibir do mais novo para o mais antigo
      */
     $oFolder = new Folder(Configure::read('Cms.CheckPoint.menus'));
     $aFolder = $oFolder->read();
     $aFiles = array_reverse($aFolder[1]);
     $aSnapshot = array();
     foreach ($aFiles as $sFile) {
         if (!in_array($sFile, array('.', '..'))) {
             $aSnapshot[$sFile] = date('d/m/Y H:i:s', str_replace('.xml', '', $sFile));
         }
     }
     if (empty($aSnapshot)) {
         $this->Session->setFlash("Nenhum ponto de restauração encontrado.", 'default', array('class' => "alert alert-error"));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     }
     $this->set(compact('aSnapshot'));
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:51,代码来源:check_points_controller.php

示例15: getForm

 /**
  * Displays the reCAPTCHA widget.
  * If $this->recaptcha_error is set, it will display an error in the widget.
  *
  */
 function getForm()
 {
     global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
     $useHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
     $js = 'var RecaptchaOptions = ' . Xml::encodeJsVar(array('theme' => $wgReCaptchaTheme, 'tabindex' => 1));
     return Html::inlineScript($js) . recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:12,代码来源:ReCaptcha.class.php


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