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


PHP SimpleXMLElement::asXML方法代码示例

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


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

示例1: cron

 protected function cron(array $args = array())
 {
     //TODO Данные об индексируемых страницах брать из ResManager
     global $general_s;
     //TODO переделать global на параметры
     $this->sxe = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>' . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
     // Главная
     $this->addUrlToSitemap('/', time(), self::NODE_CHANGEFREQ_DAILY, 1.0);
     // Категории
     $categories = $this->repositoryFactory->getCategoryRepository()->query()->getEntity(PHP_INT_MAX);
     foreach ($categories as $category) {
         $this->addUrlToSitemap("/category/{$category->id}", null, self::NODE_CHANGEFREQ_DAILY);
     }
     unset($categories);
     // Вопросы
     $mainQuestions = $this->repositoryFactory->getMainQuestionRepository()->query()->addFilterField('active', true)->getEntity(PHP_INT_MAX);
     foreach ($mainQuestions as $mainQuestion) {
         $this->addUrlToSitemap("/question/{$mainQuestion->id}", $mainQuestion->createDate);
     }
     unset($mainQuestions);
     // Сохранение XML
     $result = $this->sxe->asXML(pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_DIRNAME) . "/{$general_s['sitemap_file']}");
     if ($result === false) {
         $this->setResponseCode(HttpResponseCode::INTERNAL_SERVER_ERROR);
         $this->addResponseMessage("Ошибка создания карты сайта! Проверьте права на запись в файл " . basename($general_s['sitemap_file']), self::MESS_ERROR);
     } else {
         $this->addResponseMessage('Карта сайта успешно создана!');
     }
     unset($this->sxe);
 }
开发者ID:Ajuz,项目名称:hinter,代码行数:30,代码来源:SitemapCronController.php

示例2: buildXml

 public function buildXml($xml)
 {
     $this->root->asXML($xml);
     $xmlContent = $this->getContentXMLFile($xml);
     $this->deleteXMLFile($xml);
     return $xmlContent;
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:7,代码来源:XmlChart.php

示例3: asPrettyXML

 /**
  * Format xml with indents and line breaks
  *
  * @return string
  * @author Gary Malcolm
  */
 public function asPrettyXML()
 {
     $string = $this->_xml->asXML();
     // put each element on it's own line
     $string = preg_replace("/>\\s*</", ">\n<", $string);
     // each element to own array
     $xmlArray = explode("\n", $string);
     // holds indentation
     $currIndent = 0;
     $indent = "    ";
     // set xml element first by shifting of initial element
     $string = array_shift($xmlArray) . "\n";
     foreach ($xmlArray as $element) {
         // find open only tags... add name to stack, and print to string
         // increment currIndent
         if (preg_match('/^<([\\w])+[^>\\/]*>$/U', $element)) {
             $string .= str_repeat($indent, $currIndent) . $element . "\n";
             $currIndent += 1;
         } elseif (preg_match('/^<\\/.+>$/', $element)) {
             $currIndent -= 1;
             $string .= str_repeat($indent, $currIndent) . $element . "\n";
         } else {
             $string .= str_repeat($indent, $currIndent) . $element . "\n";
         }
     }
     return $string;
 }
开发者ID:srinathweb,项目名称:MTool,代码行数:33,代码来源:Config.php

示例4: log

 /**
  * This method saves all RatePAY Requests and Responses in the database
  * 
  * @param array $loggingInfo
  * @param SimpleXMLElement|null $request
  * @param SimpleXMLElement|null $response
  */
 public function log($loggingInfo, $request, $response)
 {
     $responseXML = '';
     $result = "Service offline.";
     $resultCode = "Service offline.";
     $reasonText = '';
     if (isset($request->content->customer->{'bank-account'})) {
         $request->content->customer->{'bank-account'}->owner = '(hidden)';
         if (isset($request->content->customer->{'bank-account'}->{'iban'})) {
             $request->content->customer->{'bank-account'}->{'iban'} = '(hidden)';
             $request->content->customer->{'bank-account'}->{'bic-swift'} = '(hidden)';
         } else {
             $request->content->customer->{'bank-account'}->{'bank-account-number'} = '(hidden)';
             $request->content->customer->{'bank-account'}->{'bank-code'} = '(hidden)';
         }
     }
     if ($response != null && isset($response) && $response->asXML() != '') {
         $result = (string) $response->head->processing->result;
         $resultCode = (string) $response->head->processing->result->attributes()->code;
         $responseXML = $response->asXML();
         $reasonText = (string) $response->head->processing->reason;
         if ($loggingInfo['requestType'] == 'PAYMENT_INIT') {
             $loggingInfo['transactionId'] = (string) $response->head->{'transaction-id'};
         }
     }
     $this->setId(null)->setOrderNumber(!empty($loggingInfo['orderId']) ? $loggingInfo['orderId'] : 'n/a')->setTransactionId(!empty($loggingInfo['transactionId']) ? $loggingInfo['transactionId'] : 'n/a')->setPaymentMethod(!empty($loggingInfo['paymentMethod']) ? $loggingInfo['paymentMethod'] : 'n/a')->setPaymentType(!empty($loggingInfo['requestType']) ? $loggingInfo['requestType'] : 'n/a')->setPaymentSubtype(!empty($loggingInfo['requestSubType']) ? $loggingInfo['requestSubType'] : 'n/a')->setResult($result)->setRequest($request->asXML())->setRequest($request->asXML())->setResponse($responseXML)->setResultCode($resultCode)->setName($loggingInfo['firstName'] . " " . $loggingInfo['lastName'])->setReason($reasonText)->save();
 }
开发者ID:ratepay,项目名称:magento-module,代码行数:34,代码来源:Logging.php

示例5: createFile

 /**
  * Export
  */
 protected function createFile()
 {
     $this->XML = new \SimpleXMLElement($this->emptyXml());
     $this->Track = $this->XML->trk->trkseg;
     $this->setTrack();
     $this->FileContent = $this->XML->asXML();
     $this->formatFileContentAsXML();
 }
开发者ID:aschix,项目名称:Runalyze,代码行数:11,代码来源:Gpx.php

示例6: dump

 /**
  * Dump manifest structure into a XML string.
  *
  * @return string
  */
 public function dump()
 {
     // Create a new XML document
     $document = new \DOMDocument('1.0', 'utf-8');
     $document->preserveWhiteSpace = false;
     $document->formatOutput = true;
     $document->loadXML($this->xml->asXML());
     return $document->saveXML();
 }
开发者ID:claroline,项目名称:distribution,代码行数:14,代码来源:AbstractScormManifest.php

示例7: createFile

 /**
  * Export
  */
 protected function createFile()
 {
     $this->XML = new \SimpleXMLElement($this->emptyXml());
     $this->Activity = $this->XML->AthleteLog->Activity;
     $this->setGeneralInfo();
     $this->setTrack();
     $this->FileContent = $this->XML->asXML();
     $this->formatFileContentAsXML();
 }
开发者ID:aschix,项目名称:Runalyze,代码行数:12,代码来源:Fitlog.php

示例8: createFile

 /**
  * Export
  */
 protected function createFile()
 {
     $this->XML = new \SimpleXMLElement($this->emptyXml());
     $this->Activity = $this->XML->Activities->Activity;
     $this->setInternalIndicators();
     $this->setGeneralInfo();
     $this->setLaps();
     $this->FileContent = $this->XML->asXML();
     $this->formatFileContentAsXML();
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:13,代码来源:Tcx.php

示例9: saveConfig

 public static function saveConfig()
 {
     $filePath = getcwd() . self::CONFIG_FOLDER . self::CONFIG_NAME;
     if (!empty(self::$configTree)) {
         $dom = new \DOMDocument("1.0");
         $dom->formatOutput = true;
         $dom->loadXML(self::$configTree->asXML());
         file_put_contents($filePath, $dom->saveXML());
     }
 }
开发者ID:swnsma,项目名称:coursework3.1,代码行数:10,代码来源:BigBrother.php

示例10: createItem

 /**
  * Insert a row into the blacklist.xml
  * 
  * @param type $type
  * @param type $table
  * @param type $colum
  */
 function createItem($type, $table, $colum)
 {
     $library = new SimpleXMLElement('xml/blacklist.xml', null, true);
     $book = $library->addChild('ITEM');
     $book->addAttribute('ID', $this->getLastIDItem() + 1);
     $book->addChild('TYPE', $type);
     $book->addChild('TABLE', $table);
     $book->addChild('COLUMN', $colum);
     echo $library->asXML();
     $library->asXML('xml/blacklist.xml');
 }
开发者ID:unPoncho,项目名称:control-asx,代码行数:18,代码来源:blackListClass.php

示例11: setFileContent

 /**
  * Set file content
  */
 protected function setFileContent()
 {
     if (!$this->Context->hasRoute() || !$this->Context->route()->hasPositionData()) {
         $this->addError(__('The training does not contain gps-data and cannot be saved as gpx-file.'));
         return;
     }
     $this->XML = new SimpleXMLElement($this->getEmptyXml());
     $this->Track = $this->XML->trk->trkseg;
     $this->setTrack();
     $this->FileContent = $this->XML->asXML();
     $this->formatFileContentAsXML();
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:15,代码来源:class.ExporterGPX.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //Проверим запущена ли команда уже, если да то выходим
     $lockHandler = new LockHandler('xml.generate.lock');
     if (!$lockHandler->lock()) {
         $output->writeln('Command is locked');
         return 0;
     }
     $email = $input->getArgument('email');
     if ($email && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new InvalidArgumentException('The argument must be valid email');
     }
     $container = $this->getContainer();
     $em = $container->get('doctrine.orm.entity_manager');
     $persons = $em->getRepository('AppBundle:Person')->findAll();
     $serializer = SerializerBuilder::create()->build();
     //ищем файл XML для экспорта, если нет - создаем
     $fs = new Filesystem();
     $path = $container->get('kernel')->getRootDir() . '/data/result.xml';
     if ($fs->exists($path)) {
         $content = file_get_contents($path);
         $xml = new \SimpleXMLElement($content);
     } else {
         $xml = new \SimpleXMLElement('<persons/>');
         $xml->asXML($path);
     }
     //идем по всем Person и ищем соответствующий айди в XML
     foreach ($persons as $person) {
         $serialized = $serializer->serialize($person, 'xml');
         $t = $xml->xpath(sprintf('//person[@id="%d"]', $person->getId()));
         if ($t) {
             //если находим - удаляем нод
             $dom = dom_import_simplexml($t[0]);
             $dom->parentNode->removeChild($dom);
         }
         //вставляем новый нод
         $target = $xml->xpath('/persons');
         $dom = dom_import_simplexml($target[0]);
         $insertDom = $dom->ownerDocument->importNode(dom_import_simplexml(new \SimpleXMLElement($serialized)), true);
         $dom->appendChild($insertDom);
     }
     $xml->asXML($path);
     $publicPath = $container->get('kernel')->getRootDir() . '/../web/' . XmlCommand::XML_PATH;
     $fs->copy($path, $publicPath);
     $timeFinished = new \DateTime();
     if ($email) {
         $context = $container->get('router')->getContext();
         $message = \Swift_Message::newInstance()->setSubject('Task finished')->setFrom('noreply@' . $context->getHost())->setTo($email)->setBody($container->get('templating')->render('emails/xmlFinished.html.twig', ['taskName' => XmlCommand::TASK_NAME, 'time' => $timeFinished, 'link' => $context->getHost() . '/' . XmlCommand::XML_PATH]), 'text/html');
         $container->get('mailer')->send($message);
     }
     return 0;
 }
开发者ID:roman-movchan,项目名称:fs-test,代码行数:52,代码来源:XmlCommand.php

示例13: setFileContent

 /**
  * Set file content
  */
 protected function setFileContent()
 {
     if (!$this->Context->hasRoute() || !$this->Context->route()->hasPositionData()) {
         $this->addError(__('The training does not contain gps-data and cannot be saved as tcx-file.'));
         return;
     }
     $this->XML = new SimpleXMLElement($this->getEmptyXml());
     $this->Activity = $this->XML->Activities->Activity;
     $this->setGeneralInfo();
     $this->setLaps();
     $this->FileContent = $this->XML->asXML();
     $this->formatFileContentAsXML();
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:16,代码来源:class.ExporterTCX.php

示例14: send

 /**
  * @param string|null $expectedResponse the response type which expected
  * @param bool $useSession should the request use an automatic session id?
  * @param bool $secondFail is this the second try of this request?
  * @return \SimpleXMLElement
  * @throws \Exception
  */
 public function send($expectedResponse = null, $useSession = true, $try = 1)
 {
     $this->request['RequestId'] = '33300000-2200-1000-0000-' . substr(md5(uniqid()), 0, 12);
     $this->request['Version'] = $this->smartHome->getVersion();
     if ($useSession) {
         $this->request['SessionId'] = $this->smartHome->getSessionId();
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'https://' . $this->smartHome->getHost() . '/' . $this->action);
     if (($clientId = $this->smartHome->getClientId()) !== null || $this->action === 'upd') {
         if ($clientId === null && $this->action === 'upd') {
             throw new \Exception('Unable to get updates if no client id is specified!', 107);
         }
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('ClientId: ' . $clientId));
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSLVERSION, 3);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $this->action === 'upd' ? 'upd' : $this->request->asXML());
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     list($header, $body) = explode("\r\n\r\n", curl_exec($ch), 2);
     $this->setResponse($body);
     $this->setResponseHeader($header);
     curl_close($ch);
     /**
      * Fix the problems
      */
     $responseType = (string) $this->getResponse()->attributes('xsi', true)->type;
     if ($expectedResponse !== null && strtolower($responseType) !== strtolower($expectedResponse)) {
         if ($try > 1) {
             throw new \Exception('Request failed second time. Error: ' . $responseType, 99);
         }
         if ($responseType === 'GenericSHCErrorResponse' || $responseType === 'AuthenticationErrorResponse') {
             $this->smartHome->login(++$try);
             return $this->send($expectedResponse, $useSession, $try);
         } else {
             $try--;
         }
         if ($responseType === 'VersionMismatchErrorResponse') {
             $this->smartHome->setVersion((string) $this->getResponse()->attributes()->ExpectedVersion);
             return $this->send($expectedResponse, $useSession, ++$try);
         } else {
             $try--;
         }
     }
     return $this->getResponse();
 }
开发者ID:bendspoons,项目名称:SmartHome-PHP,代码行数:57,代码来源:BaseRequest.php

示例15: execute

 public function execute()
 {
     //Build command arguments..
     foreach ($this->arguments as $arg) {
         $this->command->addChild("arg", $arg);
     }
     $reqStr = $this->request->asXML();
     $curl = curl_init("http://localhost:8181/rpc/surrogate_api/xmlcmd");
     curl_setopt($curl, CURLOPT_POST, TRUE);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $reqStr);
     //echo "Requesting: \n$reqStr\n\n";
     $this->response = curl_exec($curl);
     curl_close($curl);
 }
开发者ID:yuxw75,项目名称:Surrogate,代码行数:15,代码来源:SurrogateXMLCommand.php


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