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


PHP SimpleXMLExtended::addCData方法代码示例

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


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

示例1: saveTemplate

 function saveTemplate($data)
 {
     My_Logger::log("in Ajax_TemplateEditorProcessor saveTemplate()");
     $expected = array('filename', 'type', 'time', 'concepts', 'instructions', 'problem');
     $filename = $this->get($data['filename']);
     if (empty($filename)) {
         throw new Exception('Missing Filename');
     }
     My_Logger::log("filename is " . $filename);
     foreach ($expected as $field) {
         $toCheck = $this->get($data[$field]);
         if (empty($toCheck)) {
             //if (empty($this->get($data[$field]))){
             throw new Exception('Missing field: ' . $field);
         }
     }
     //build xml
     $xml = new SimpleXMLExtended('<question/>');
     $xml->addAttribute('type', $this->get($data['type']));
     $xml->addChild('estimated_time', $this->get($data['time']));
     $concepts = $xml->addChild('concepts');
     $concepts->addChild('concept', $this->get($data['concepts']));
     $xml->addChild('difficulty', $this->get($data['difficulty']));
     $xml->addChild('instructions', $this->get($data['instructions']));
     //$xml->problem = null;
     //$xml->problem->addCData($this->get($data['problem']));
     $xml->addCData('problem', $this->get($data['problem']));
     $sc = $xml->addChild('substitutions');
     $subs = $this->get($data['s']);
     if ($subs) {
         foreach ($subs as $sd) {
             if (empty($sd['name']) || empty($sd['value'])) {
                 continue;
             }
             $s = $sc->addCData('substitution', $sd['value']);
             $s->addAttribute('val', $sd['name']);
         }
     }
     $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV);
     $path = $config->xml->import_path;
     $full_filename = $path . DIRECTORY_SEPARATOR . $filename;
     My_Logger::log("Saving to {$full_filename}");
     $xml->saveXML($full_filename);
     chmod($full_filename, 0666);
     return array('result' => 'success', 'msg' => "File '{$filename}' saved correctly");
 }
开发者ID:sutantyo,项目名称:itec810,代码行数:46,代码来源:TemplateEditorProcessor.php

示例2: errorsAddToXML

 /**
  * add the errors to an existing xml document
  *
  * @param String $encoding encoding
  *
  * @return SimpleXmlElement
  */
 public function errorsAddToXML($encoding)
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElement("Errors");
     $dom->appendChild($root);
     $xml = simplexml_import_dom($dom);
     $xmlerr = new SimpleXMLExtended($xml, $encoding);
     foreach ($this->_arrErrorList as $arrLine) {
         $error = $xmlerr->addCData('Error', $arrLine['message']);
         $error->addAttribute('Function', $arrLine['command']);
     }
     return $xmlerr->getSimpleXmlElement();
 }
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:20,代码来源:class.Error.inc.php

示例3: outputObject

 /**
  * @brief Create the XML output of the AREL Object and send it to the junaio server.
  * @param ArelObject $oObject Object to be sent out
  */
 public static function outputObject($oObject)
 {
     $object = new SimpleXMLExtended("<object></object>");
     $object->addAttribute('id', (string) $oObject->getID());
     if ($oObject->getTitle()) {
         $object->addCData('title', $oObject->getTitle());
     }
     if ($oObject->getThumbnail()) {
         $object->addCData('thumbnail', $oObject->getThumbnail());
     }
     if ($oObject->getIcon()) {
         $object->addCData('icon', $oObject->getIcon());
     }
     //location
     if ($oObject->getLocation()) {
         $location = $object->addChild("location");
         $oLocation = $oObject->getLocation();
         try {
             $location->addChild('lat', $oLocation[0]);
             $location->addChild('lon', $oLocation[1]);
             if (isset($oLocation[2])) {
                 $location->addChild('alt', $oLocation[2]);
             } else {
                 $location->addChild('alt', 0);
             }
         } catch (Exception $e) {
             return $e;
         }
     }
     //popup
     if ($oObject->getPopup()) {
         $popup = $object->addChild("popup");
         $oPopUp = $oObject->getPopup();
         if ($oPopUp->getDescription()) {
             $popup->addCData('description', $oPopUp->getDescription());
         }
         if ($oPopUp->getButtons()) {
             $buttons = $popup->addChild("buttons");
             $aButtons = $oPopUp->getButtons();
             foreach ($aButtons as $oButton) {
                 $button = $buttons->addCData("button", $oButton[2]);
                 $button->addAttribute("id", $oButton[1]);
                 $button->addAttribute("name", $oButton[0]);
             }
         }
     }
     if ($oObject instanceof ArelObjectModel3D) {
         //assets3D
         $assets3D = $object->addChild("assets3d");
         if ($oObject->getModel()) {
             $assets3D->addCData('model', $oObject->getModel());
         }
         if ($oObject->getMovie()) {
             $assets3D->addCData('movie', $oObject->getMovie());
         }
         if ($oObject->getTexture()) {
             $assets3D->addCData('texture', $oObject->getTexture());
         }
         //transform
         $transform = $assets3D->addChild("transform");
         $oTransform = $oObject->getTransformParent();
         if (isset($oTransform)) {
             $transform->addAttribute("parent", $oTransform);
         }
         try {
             //translation
             $translation = $transform->addChild("translation");
             $oTranslation = $oObject->getTranslation();
             $translation->addChild("x", $oTranslation[0]);
             $translation->addChild("y", $oTranslation[1]);
             $translation->addChild("z", $oTranslation[2]);
             //rotation
             $rotation = $transform->addChild("rotation");
             $oRotationElement = $oObject->getRotation();
             $oRotation = $oRotationElement->getRotationValues();
             $oRotationType = $oRotationElement->getRotationType();
             $rotation->addAttribute("type", $oRotationType);
             if ($oRotationType !== ArelRotation::ROTATION_MATRIX) {
                 $rotation->addChild("x", $oRotation[0]);
                 $rotation->addChild("y", $oRotation[1]);
                 $rotation->addChild("z", $oRotation[2]);
                 if ($oRotationType == ArelRotation::ROTATION_QUATERNION) {
                     $rotation->addChild("w", $oRotation[3]);
                 } else {
                     if ($oRotationType == ArelRotation::ROTATION_AXISANGLE) {
                         $rotation->addChild("angle", $oRotation[3]);
                     }
                 }
             } else {
                 $rotation->addChild("m0", $oRotation[0]);
                 $rotation->addChild("m1", $oRotation[1]);
                 $rotation->addChild("m2", $oRotation[2]);
                 $rotation->addChild("m3", $oRotation[3]);
                 $rotation->addChild("m4", $oRotation[4]);
                 $rotation->addChild("m5", $oRotation[5]);
                 $rotation->addChild("m6", $oRotation[6]);
//.........这里部分代码省略.........
开发者ID:Mynameisjack2014,项目名称:junaio-quickstarts,代码行数:101,代码来源:arel_xmlhelper.class.php


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