當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SimpleXMLIterator::asXML方法代碼示例

本文整理匯總了PHP中SimpleXMLIterator::asXML方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleXMLIterator::asXML方法的具體用法?PHP SimpleXMLIterator::asXML怎麽用?PHP SimpleXMLIterator::asXML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleXMLIterator的用法示例。


在下文中一共展示了SimpleXMLIterator::asXML方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileInfo = new \SplFileInfo($this->getContainer()->getParameter('kernel.root_dir') . '/../web/sitemap.xml');
     if ($fileInfo->isFile() && $fileInfo->isReadable()) {
         $output->write('Reading sitemap.xml...');
         $file = $fileInfo->openFile();
         $xml = '';
         while (!$file->eof()) {
             $xml .= $file->fgets();
         }
         $output->writeln(' done.');
         $output->write('Updating sitemap.xml...');
         $sitemap = new \SimpleXMLIterator($xml);
         $sitemap->rewind();
         $lastmodDate = new \DateTime();
         $lastmodDate->sub(new \DateInterval('P1D'));
         $lastmodDateFormatted = $lastmodDate->format('Y-m-d');
         while ($sitemap->valid()) {
             $sitemap->current()->lastmod = $lastmodDateFormatted;
             $sitemap->next();
         }
         $file = $file->openFile('w');
         $file->fwrite($sitemap->asXML());
         $output->writeln(' done.');
     } else {
         $output->writeln('Error: Cannot open file web/sitemap.xml');
     }
 }
開發者ID:Quiss,項目名稱:Evrika,代碼行數:28,代碼來源:UpdateSitemapCommand.php

示例2: asXML

 public function asXML($filename = null)
 {
   if (!$this->_iso()) return $filename ? parent::asXML($filename) : parent::asXML();
   $xml = @parent::asXML();
   $xml = utf8_decode($xml);
   if ($filename) file_put_contents($filename, $xml);
   return $xml;
 }
開發者ID:neves,項目名稱:qi,代碼行數:8,代碼來源:element.php

示例3: getFormUploadFields

 /**
  * get files to be uploaded
  * @param object \SimpleXMLIterator $data data
  * @return array
  */
 public function getFormUploadFields($data)
 {
     $data = new \SimpleXMLIterator($data->asXML());
     if (isset($data->values->values->formId)) {
         $object = new \stdClass();
         $object->id = $data->values->values->formId;
         $object->fields = array('xmlDefinition');
         $res = $this->getOne($object);
         $formXml = file_get_contents('/var/www/htdocs/uploads/' . $res['fields']['xmlDefinition']);
         $formXml = new \SimpleXMLIterator($formXml);
         $uploadsFields = $formXml->xpath('//input[@type="file"]');
         foreach ($uploadsFields as $field) {
             $controlName = (string) $field['name'];
             $control = $data->xpath('//' . $controlName);
             $fieldAnswers[] = array('fieldName' => $controlName, 'value' => (string) $control[0]);
         }
         return array('fields' => $fieldAnswers);
     } else {
         return false;
     }
 }
開發者ID:EngrHaiderAli,項目名稱:movein-servie,代碼行數:26,代碼來源:FormConfig.php

示例4: updateAPP

 protected function updateAPP()
 {
     if (is_file($this->applist) && is_writable($this->applist)) {
         try {
             $doc = new SimpleXMLIterator($this->applist, null, true);
         } catch (Exception $e) {
             $this->error[] = "發生異常:" . $e->getMessage() . "  文件:" . $e->getFile() . "  行號:" . $e->getLine();
             return false;
         }
         if ($doc->getName() != "apps") {
             $this->error[] = "applist.xml的根元素必須是apps";
             return false;
         }
         $i = $doc->count();
         if ($i !== 0) {
             $apps = $doc->app;
             foreach ($apps as $app) {
                 if ($app['name'] == $this->app_name) {
                     $this->error[] = "項目列表存在重名項目,請修改項目名稱";
                     return false;
                 }
             }
         }
         $doc->addChild("app");
         $doc->app[$i]->addAttribute("name", $this->app_name);
         $doc->app[$i]->addAttribute("path", $this->app_path);
         $doc->app[$i]->addAttribute("index", $this->app_index);
         if ($doc->asXML($this->applist)) {
             return true;
         } else {
             $this->error[] = "TinkPHP助手/data/applist.xml 寫入失敗";
             return false;
         }
     } else {
         $this->error[] = "TinkPHP助手/data/applist.xml不存在";
         return false;
     }
 }
開發者ID:sdgdsffdsfff,項目名稱:TPhelper,代碼行數:38,代碼來源:AdminAction.class.php


注:本文中的SimpleXMLIterator::asXML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。