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


PHP XMLParser::getTree方法代码示例

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


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

示例1: handle


//.........这里部分代码省略.........
     if (preg_match('/sortprice/i', $more, $match)) {
         $params['sort'] = 'Price';
     } elseif (preg_match('/sortpriority/i', $more, $match)) {
         $params['sort'] = 'Priority';
     } elseif (preg_match('/sortadded/i', $more, $match)) {
         $params['sort'] = 'DateAdded';
     }
     // no country given?
     if (empty($asin)) {
         $asin = $ctry;
         $ctry = 'us';
     }
     // correct country given?
     if (!preg_match('/^(us|uk|jp|de|fr|ca)$/', $ctry)) {
         $ctry = 'us';
     }
     // get partner id
     $partner = $this->getConf('partner_' . $ctry);
     // correct domains
     if ($ctry == 'us') {
         $ctry = 'com';
     }
     if ($ctry == 'uk') {
         $ctry = 'co.uk';
     }
     // basic API parameters
     $opts = array();
     $opts['Service'] = 'AWSECommerceService';
     $opts['AWSAccessKeyId'] = AMAZON_APIKEY;
     $opts['AssociateTag'] = $partner;
     if ($type == 'product') {
         // parameters for querying a single product
         $opts['Operation'] = 'ItemLookup';
         $opts['ResponseGroup'] = 'Medium,OfferSummary';
         if (strlen($asin) < 13) {
             $opts['IdType'] = 'ASIN';
             $opts['ItemId'] = $asin;
         } else {
             $opts['SearchIndex'] = 'Books';
             $opts['IdType'] = 'ISBN';
             $opts['ItemId'] = $asin;
         }
     } else {
         // parameters to query a wishlist
         $opts['Operation'] = 'ListLookup';
         $opts['ResponseGroup'] = 'ListItems,Medium,OfferSummary';
         $opts['ListId'] = $asin;
         $opts['Sort'] = $params['sort'];
         $opts['IsIncludeUniversal'] = 'True';
         $opts['IsOmitPurchasedItems'] = $params['purchased'] ? 'False' : 'True';
         if ($type == 'wishlist') {
             $opts['ListType'] = 'WishList';
         } else {
             $opts['ListType'] = 'Listmania';
         }
     }
     // support paged results
     $result = array();
     $pages = 1;
     for ($page = 1; $page <= $pages; $page++) {
         $opts['ProductPage'] = $page;
         // fetch it
         $http = new DokuHTTPClient();
         $url = $this->_signedRequestURI($ctry, $opts, $this->getConf('publickey'), $this->getConf('privatekey'));
         $xml = $http->get($url);
         if (empty($xml)) {
             if ($http->error) {
                 return $http->error;
             }
             if ($http->status == 403) {
                 return 'Signature check failed, did you set your Access Keys in config?';
             }
             return 'unkown error';
         }
         // parse it
         require_once dirname(__FILE__) . '/XMLParser.php';
         $xmlp = new XMLParser($xml);
         $data = $xmlp->getTree();
         //dbg($data);
         // check for errors and return the item(s)
         if ($type == 'product') {
             // error?
             if ($data['ITEMLOOKUPRESPONSE'][0]['ITEMS'][0]['REQUEST'][0]['ERRORS']) {
                 return $data['ITEMLOOKUPRESPONSE'][0]['ITEMS'][0]['REQUEST'][0]['ERRORS'][0]['ERROR'][0]['MESSAGE'][0]['VALUE'];
             }
             // return item
             $result = array_merge($result, (array) $data['ITEMLOOKUPRESPONSE'][0]['ITEMS'][0]['ITEM']);
         } else {
             // error?
             if ($data['LISTLOOKUPRESPONSE'][0]['LISTS'][0]['REQUEST'][0]['ERRORS']) {
                 return $data['LISTLOOKUPRESPONSE'][0]['LISTS'][0]['REQUEST'][0]['ERRORS'][0]['ERROR'][0]['MESSAGE'][0]['VALUE'];
             }
             // multiple pages?
             $pages = (int) $data['LISTLOOKUPRESPONSE'][0]['LISTS'][0]['LIST'][0]['TOTALPAGES'][0]['VALUE'];
             // return items
             $result = array_merge($result, (array) $data['LISTLOOKUPRESPONSE'][0]['LISTS'][0]['LIST'][0]['LISTITEM']);
         }
     }
     return array($result, $params);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:101,代码来源:syntax.php

示例2: strtoupper

 /**
  * Get Xml Array.
  * If xml file has been compiled (has .cmp), load the cmp file as array;
  * otherwise, compile the .xml to .cmp first new 2.2.3, .cmp files
  * will be created in app/cache/metadata_cmp directory. replace '/' with '_'
  * for example, /module/demo/BOEvent.xml has cmp file as _module_demo_BOEvent.xml
  *
  * @param string $xmlFile
  * @return array
  * */
 public static function &getXmlArray($xmlFile)
 {
     if (isset(self::$_xmlArrayList[$xmlFile])) {
         return self::$_xmlArrayList[$xmlFile];
     }
     $objXmlFileName = $xmlFile;
     //echo "getXmlArray($xmlFile)\n";
     //$objCmpFileName = dirname($objXmlFileName) . "/__cmp/" . basename($objXmlFileName, "xml") . ".cmp";
     //$_crc32 = sprintf('%08X', crc32(dirname($objXmlFileName)));
     $_crc32 = strtoupper(md5(dirname($objXmlFileName)));
     $objCmpFileName = CACHE_METADATA_PATH . '/' . $_crc32 . '_' . basename($objXmlFileName, "xml") . "cmp";
     $xmlArr = null;
     //$cacheKey = substr($objXmlFileName, strlen(META_PATH)+1);
     $cacheKey = $objXmlFileName;
     $findInCache = false;
     if (file_exists($objCmpFileName) && filemtime($objCmpFileName) > filemtime($objXmlFileName)) {
         // search in cache first
         if (!$xmlArr && extension_loaded('apc')) {
             if (($xmlArr = apc_fetch($cacheKey)) != null) {
                 $findInCache = true;
             }
         }
         if (!$xmlArr) {
             $content_array = file($objCmpFileName);
             $xmlArr = unserialize(implode("", $content_array));
         }
     } else {
         if (extension_loaded('ionCube Loader')) {
             include_once OPENBIZ_BIN . "util/xmltoarray.php";
         } else {
             include_once OPENBIZ_BIN . "util/xmltoarray.src.php";
         }
         $parser = new XMLParser($objXmlFileName, 'file', 1);
         $xmlArr = $parser->getTree();
         // simple validate the xml array
         $root_keys = array_keys($xmlArr);
         $root_key = $root_keys[0];
         if (!$root_key || $root_key == "") {
             trigger_error("Metadata file parsing error for file {$objXmlFileName}. Please double check your metadata xml file again.", E_USER_ERROR);
         }
         $xmlArrStr = serialize($xmlArr);
         if (!file_exists(dirname($objCmpFileName))) {
             mkdir(dirname($objCmpFileName));
         }
         $cmp_file = fopen($objCmpFileName, 'w') or die("can't open cmp file to write");
         fwrite($cmp_file, $xmlArrStr) or die("can't write to the cmp file");
         fclose($cmp_file);
     }
     // save to cache to avoid file processing overhead
     if (!$findInCache && extension_loaded('apc')) {
         apc_store($cacheKey, $xmlArr);
     }
     self::$_xmlArrayList[$xmlFile] = $xmlArr;
     return $xmlArr;
 }
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:65,代码来源:Resource.php

示例3: xmlMap

 /**
  * Erzeugt die Kartendarstellung aus einer XML Datei
  *
  * @param string $file XML Datei
  * @return bool
  */
 function xmlMap($file)
 {
     $parser = new XMLParser($file, 'file', 1);
     $tree = $parser->getTree();
     $lat = $tree[MAP][STARTLAT][VALUE];
     $lng = $tree[MAP][STARTLONG][VALUE];
     $width = $tree[MAP][WIDTH][VALUE];
     $height = $tree[MAP][HEIGHT][VALUE];
     $min_zoom = $tree[MAP][MINZOOM][VALUE];
     $typ = $tree[MAP][MAPTYPE][VALUE];
     $zoom = $tree[MAP][STARTZOOM][VALUE];
     if (!$min_zoom) {
         $min_zoom = 1;
     }
     $max_zoom = $tree[MAP][MAXZOOM][VALUE];
     if (!$max_zoom) {
         $max_zoom = 17;
     }
     $navcontrol = $tree[MAP][NAVCONTROL][VALUE];
     $width = $width . "px";
     $height = $height . "px";
     if ($typ == "normal") {
         $typstr = "G_NORMAL_MAP";
     } elseif ($typ == "satellit") {
         $typstr = "G_SATELLITE_MAP";
     } elseif ($typ == "hybrid") {
         $typstr = "G_HYBRID_MAP";
     }
     if ($navcontrol == "large") {
         $controlstr = "GLargeMapControl()";
     } elseif ($navcontrol == "small") {
         $controlstr = "GSmallMapControl()";
     }
     echo "\n\t\t<script type=\"text/javascript\">\n\n\t\tvar map = new GMap2(document.getElementById(\"gmapper_map\"));\n\n\t\tmap.addControl(new {$controlstr});\n\n\t\tmap.addControl(new GMapTypeControl());\n\n\t\tmap.enableDoubleClickZoom();\n\n\t\tmap.enableContinuousZoom();\n\n\t\tvar mt = map.getMapTypes();\n\n\t\t      for (var i=0; i<mt.length; i++) {\n\t\t        mt[i].getMinimumResolution = function() {return {$min_zoom};}\n\t\t        mt[i].getMaximumResolution = function() {return {$max_zoom};}\n\t\t      }\n\t\tmap.addControl(new GMapTypeControl());\n\n\t\tmap.setCenter(new GLatLng( {$lat},{$lng}),{$zoom});\n\n\n\t\tmap.setMapType({$typstr});\n\n\t\t</script>";
     return true;
 }
开发者ID:Wings1986,项目名称:SMBeacon-IOS-Web,代码行数:42,代码来源:class.gmapper.php


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