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


PHP Varien_Simplexml_Element::xmlentities方法代码示例

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


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

示例1: extendChild

 /**
  * Extends one node
  *
  * @param Varien_Simplexml_Element $source
  * @param boolean $overwrite
  * @return Varien_Simplexml_Element
  */
 public function extendChild($source, $overwrite = false)
 {
     // this will be our new target node
     $targetChild = null;
     // name of the source node
     $sourceName = $source->getName();
     // here we have children of our source node
     $sourceChildren = $source->children();
     if (!$source->hasChildren()) {
         // handle string node
         if (isset($this->{$sourceName})) {
             // if target already has children return without regard
             if ($this->{$sourceName}->hasChildren()) {
                 return $this;
             }
             if ($overwrite) {
                 unset($this->{$sourceName});
             } else {
                 return $this;
             }
         }
         $targetChild = $this->addChild($sourceName, $source->xmlentities());
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
         return $this;
     }
     if (isset($this->{$sourceName})) {
         $targetChild = $this->{$sourceName};
     }
     if (is_null($targetChild)) {
         // if child target is not found create new and descend
         $targetChild = $this->addChild($sourceName);
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
     }
     // finally add our source node children to resulting new target node
     foreach ($sourceChildren as $childKey => $childNode) {
         $targetChild->extendChild($childNode, $overwrite);
     }
     return $this;
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:52,代码来源:Element.php

示例2: __toXml

 /**
  * Convert object attributes to XML
  *
  * @param  array $arrAttributes array of required attributes
  * @param string $rootName name of the root element
  * @return string
  */
 protected function __toXml(array $arrAttributes = array(), $rootName = 'item', $addOpenTag = false, $addCdata = true)
 {
     $xml = '';
     if ($addOpenTag) {
         $xml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     }
     if (!empty($rootName)) {
         $xml .= '<' . $rootName . '>' . "\n";
     }
     $xmlModel = new Varien_Simplexml_Element('<node></node>');
     $arrData = $this->toArray($arrAttributes);
     foreach ($arrData as $fieldName => $fieldValue) {
         if ($addCdata === true) {
             $fieldValue = "<![CDATA[{$fieldValue}]]>";
         } else {
             $fieldValue = $xmlModel->xmlentities($fieldValue);
         }
         $xml .= "<{$fieldName}>{$fieldValue}</{$fieldName}>" . "\n";
     }
     if (!empty($rootName)) {
         $xml .= '</' . $rootName . '>' . "\n";
     }
     return $xml;
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:31,代码来源:Object.php


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