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


PHP SimpleXMLObject::getName方法代码示例

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


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

示例1: loadXML

 /**
  * Takes in XML data and converts it to an array for the object to use.
  * @param SimpleXMLObject $xml <p>XML Product data from Amazon</p>
  * @return boolean <b>FALSE</b> if no XML data is found
  */
 public function loadXML($xml)
 {
     if (!$xml) {
         return false;
     }
     $this->data = array();
     //Categories first
     if ($xml->getName() == 'GetProductCategoriesForSKUResult' || $xml->getName() == 'GetProductCategoriesForASINResult') {
         $this->loadCategories($xml);
         return;
     }
     if ($xml->getName() != 'Product') {
         return;
     }
     //Identifiers
     if ($xml->Identifiers) {
         foreach ($xml->Identifiers->children() as $x) {
             foreach ($x->children() as $z) {
                 $this->data['Identifiers'][$x->getName()][$z->getName()] = (string) $z;
             }
         }
     }
     //AttributeSets
     if ($xml->AttributeSets) {
         $anum = 0;
         foreach ($xml->AttributeSets->children('ns2', true) as $aset) {
             foreach ($aset->children('ns2', true) as $x) {
                 if ($x->children('ns2', true)->count() > 0) {
                     //another layer
                     foreach ($x->children('ns2', true) as $y) {
                         if ($y->children('ns2', true)->count() > 0) {
                             //we need to go deeper
                             foreach ($y->children('ns2', true) as $z) {
                                 if ($z->children('ns2', true)->count() > 0) {
                                     //we need to go deeper
                                     $this->log('Warning! Attribute ' . $z->getName() . ' is too deep for this!', 'Urgent');
                                 } else {
                                     $this->data['AttributeSets'][$anum][$x->getName()][$y->getName()][$z->getName()] = (string) $z;
                                 }
                             }
                         } else {
                             $this->data['AttributeSets'][$anum][$x->getName()][$y->getName()] = (string) $y;
                         }
                     }
                 } else {
                     //Check for duplicates
                     if (array_key_exists('AttributeSets', $this->data) && array_key_exists($anum, $this->data['AttributeSets']) && array_key_exists($x->getName(), $this->data['AttributeSets'][$anum])) {
                         //check for previous cases of duplicates
                         if (is_array($this->data['AttributeSets'][$anum][$x->getName()])) {
                             $this->data['AttributeSets'][$anum][$x->getName()][] = (string) $x;
                         } else {
                             //first instance of duplicates, make into array
                             $temp = array($this->data['AttributeSets'][$anum][$x->getName()]);
                             $this->data['AttributeSets'][$anum][$x->getName()] = $temp;
                             $this->data['AttributeSets'][$anum][$x->getName()][] = (string) $x;
                         }
                     } else {
                         //no duplicates
                         $this->data['AttributeSets'][$anum][$x->getName()] = (string) $x;
                     }
                 }
             }
             $anum++;
         }
     }
     //Relationships
     if ($xml->Relationships) {
         foreach ($xml->Relationships->children() as $x) {
             foreach ($x->children() as $y) {
                 foreach ($y->children() as $z) {
                     foreach ($z->children() as $zzz) {
                         $this->data['Relationships'][$x->getName()][$y->getName()][$z->getName()][$zzz->getName()] = (string) $zzz;
                     }
                 }
             }
         }
     }
     //CompetitivePricing
     if ($xml->CompetitivePricing) {
         //CompetitivePrices
         foreach ($xml->CompetitivePricing->CompetitivePrices->children() as $pset) {
             $pnum = (string) $pset->CompetitivePriceId;
             $temp = (array) $pset->attributes();
             $belongs = $temp['@attributes']['belongsToRequester'];
             $con = $temp['@attributes']['condition'];
             $sub = $temp['@attributes']['subcondition'];
             $this->data['CompetitivePricing']['CompetitivePrices'][$pnum]['belongsToRequester'] = $belongs;
             $this->data['CompetitivePricing']['CompetitivePrices'][$pnum]['condition'] = $con;
             $this->data['CompetitivePricing']['CompetitivePrices'][$pnum]['subcondition'] = $sub;
             foreach ($pset->Price->children() as $x) {
                 //CompetitivePrice->Price
                 foreach ($x->children() as $y) {
                     $this->data['CompetitivePricing']['CompetitivePrices'][$pnum]['Price'][$x->getName()][$y->getName()] = (string) $y;
                 }
             }
//.........这里部分代码省略.........
开发者ID:zaffar-saffee,项目名称:laravel-5-amazon-mws-persistent,代码行数:101,代码来源:AmazonProduct.php


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