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


PHP SimpleXMLElement::__toString方法代码示例

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


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

示例1: mapChildElements

 /**
  *  Map the child elements of the current element, to the properties of the GpxElement object
  *
  *  @param   \SimpleXMLElement      $element     The element that we want to reformat as an object
  *  @return  \GpxReader\GpxElement  $gpxElement  The object that we want to set the properties for
  **/
 protected function mapChildElements($element, GpxElement $gpxElement)
 {
     switch ($element->getName()) {
         case 'ele':
             $gpxElement->elevation = (double) $element->__toString();
             break;
         case 'time':
             $gpxElement->timestamp = new \DateTime($element->__toString());
             break;
     }
 }
开发者ID:MarkBaker,项目名称:GeneratorFunctionExamples,代码行数:17,代码来源:GpxHandler.php

示例2: childProdParse

 /**
  * Recusive function for parseProducts
  *
  * @param SimpleXMLElement $c The SimpleXMLElement object to parse
  * @param int $depth Not used
  * @param array $prod Custom associative array to store the parsed children
  */
 public function childProdParse($c, $depth, $prod)
 {
     $name = $c->getName();
     $value = $c->__toString();
     if ($name == "Custom") {
         $prod['cust_' . $c['id']->__toString()] = $value;
     } elseif (isset($prod[$name])) {
         if ($c->children()->count() || $c->attributes()) {
             $value = ['v' => $value];
         }
         if ($c->attributes()) {
             $value['_attr'] = [];
             foreach ($c->attributes() as $a => $b) {
                 $value['_attr'][$a] = $b->__toString();
             }
         }
         if ($c->children()->count()) {
             $value['_children'] = [];
             foreach ($c->children() as $cc) {
                 $value['_children'] = $this->childProdParse($cc, $depth + 1, $value['_children']);
             }
         }
         if (is_array($prod[$name]) && !isset($prod[$name]['v'])) {
             $prod[$name][] = $value;
         } else {
             $prod[$name] = [$prod[$name], $value];
         }
     } else {
         if ($c->children()->count() || $c->attributes()) {
             $prod[$name] = ['v' => $value];
         } else {
             // if($name == "Image"){
             // $prod[$name] = [[$value]];
             // }else
             $prod[$name] = $value;
         }
         if ($c->attributes()) {
             $prod[$name]['_attr'] = [];
             foreach ($c->attributes() as $a => $b) {
                 $prod[$name]['_attr'][$a] = $b->__toString();
             }
         }
         if ($c->children()->count()) {
             $prod[$name]['_children'] = [];
             foreach ($c->children() as $cc) {
                 $prod[$name]['_children'] = $this->childProdParse($cc, $depth + 1, $prod[$name]['_children']);
             }
         }
         if ($name == "Image") {
             $prod[$name] = [$prod[$name]];
         }
     }
     return $prod;
 }
开发者ID:frostbitten,项目名称:-not-endorsed-Open-Docs-for-CV3,代码行数:61,代码来源:xml.php

示例3: handle

 public function handle(ResponseCore $response)
 {
     $xml = new SimpleXMLElement($response->body);
     $location = $xml->__toString();
     return $location;
 }
开发者ID:maigoxin,项目名称:easylib,代码行数:6,代码来源:Handlers.php


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