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


PHP Xml::toXml方法代码示例

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


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

示例1: createManifestFile

 private function createManifestFile()
 {
     //------------------------- 创建xml文件 start
     //创建xml文件
     $xml_data['application'] = ['name' => ['@cdata' => $_POST['name']], 'title' => ['@cdata' => $_POST['title']], 'url' => ['@cdata' => $_POST['url']], 'industry' => ['@cdata' => $_POST['industry']], 'version' => ['@cdata' => $_POST['version']], 'resume' => ['@cdata' => $_POST['resume']], 'author' => ['@cdata' => $_POST['author']], 'position' => ['@cdata' => $_POST['position']], 'thumb' => ['@cdata' => $_POST['thumb']], 'module' => ['@cdata' => $_POST['module']]];
     $manifest = Xml::toXml('manifest', $xml_data);
     file_put_contents('theme/' . $_POST['name'] . '/manifest.xml', $manifest);
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:8,代码来源:Template.php

示例2: toXml

 public static function toXml($data, $parent = 'root')
 {
     if (!$parent instanceof XmlNode) {
         $parent = new XmlElement((string) $parent);
     }
     switch (true) {
         case is_array($data):
         case is_object($data):
             $parent->setAttribute('type', 'structure');
             foreach ($data as $key => $value) {
                 if (is_int($key)) {
                     $key = 'element';
                 }
                 $node = new XmlElement($key);
                 $parent->addChild($node);
                 Xml::toXml($value, $node);
             }
             break;
         case is_bool($data):
             $parent->setAttribute('type', 'boolean');
             $parent->addChild(new XmlText($data ? 'true' : 'false'));
             break;
         case is_int($data):
             $parent->setAttribute('type', 'integer');
             $parent->addChild(new XmlText($data));
             break;
         case is_string($data):
             $parent->setAttribute('type', 'string');
             $parent->addChild(new XmlText($data));
             break;
         case is_float($data):
             $parent->setAttribute('type', 'float');
             $parent->addChild(new XmlText($data));
             break;
         case is_double($data):
             $parent->setAttribute('type', 'double');
             $parent->addChild(new XmlText($data));
             break;
         case is_null($data):
             //break;
         //break;
         default:
             $parent->addChild(new XmlText($data));
             break;
     }
     return $parent;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:47,代码来源:Xml.php

示例3: asXml

 protected function asXml($value, $rootName = 'response')
 {
     $this->setSkipView(true);
     $xml = Xml::toXml($value, $rootName);
     header('Content-type: text/xml');
     echo $xml;
     Pimple::instance()->end();
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:8,代码来源:Controller.php

示例4: createManifestFile

 private function createManifestFile()
 {
     //------------------------- 创建xml文件 start
     //模块动作
     $bindings = [];
     foreach (['cover', 'rule', 'business', 'home', 'profile', 'member', 'web'] as $type) {
         $d = $_POST['bindings'][$type];
         foreach ($d['title'] as $k => $v) {
             if (!empty($d['title'][$k]) && preg_match('/^\\w+$/i', $d['do'][$k])) {
                 $bindings[$type]['entry'][] = ['@attributes' => ['title' => $d['title'][$k], 'do' => $d['do'][$k], 'data' => $d['data'][$k], 'directly' => isset($d['directly'][$k]) ? $d['directly'][$k] : TRUE]];
             }
         }
     }
     //消息处理
     $platformXml = ['subscribes' => [], 'processors' => []];
     if (isset($_POST['subscribes'])) {
         foreach ($_POST['subscribes'] as $m) {
             $platformXml['subscribes']['message'][] = ['@attributes' => ['type' => $m]];
         }
     }
     if (isset($_POST['processors'])) {
         foreach ($_POST['processors'] as $m) {
             $platformXml['processors']['message'][] = ['@attributes' => ['type' => $m]];
         }
     }
     //创建xml文件
     $xml_data = ['@attributes' => ['versionCode' => implode(',', $_POST['versionCode'])], 'application' => ['@attributes' => ['setting' => isset($_POST['setting']) ? TRUE : FALSE], 'name' => ['@cdata' => $_POST['name']], 'title' => ['@cdata' => $_POST['title']], 'url' => ['@cdata' => $_POST['url']], 'version' => ['@cdata' => $_POST['version']], 'industry' => ['@cdata' => $_POST['industry']], 'resume' => ['@cdata' => $_POST['resume']], 'detail' => ['@cdata' => $_POST['detail']], 'author' => ['@cdata' => $_POST['author']], 'industry' => ['@cdata' => $_POST['industry']], 'thumb' => ['@cdata' => $_POST['thumb']], 'cover' => ['@cdata' => $_POST['cover']], 'rule' => ['@attributes' => ['embed' => isset($_POST['rule']) ? $_POST['rule'] : FALSE]]], 'platform' => $platformXml, 'bindings' => $bindings, 'permission' => ['@cdata' => $_POST['permission']], 'install' => ['@cdata' => $_POST['install']], 'uninstall' => ['@cdata' => $_POST['uninstall']], 'upgrade' => ['@cdata' => $_POST['upgrade']]];
     $manifest = Xml::toXml('manifest', $xml_data);
     file_put_contents('addons/' . $_POST['name'] . '/manifest.xml', $manifest);
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:30,代码来源:Module.php


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