當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。