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


PHP SimpleXMLElement::getName方法代码示例

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


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

示例1: index

 /**
  * Add item index and level to class attribute
  *
  * @param  SimpleXMLElement $node The node to add the index and level to
  * @param  array            $args Callback arguments
  */
 public static function index(SimpleXMLElement $node, $args)
 {
     if ($node->getName() == 'ul') {
         // set up level
         $level = $args['level'] / 2 + 1;
         if ($level > 1) {
             $node->addAttribute('class', 'uk-nav uk-nav-navbar');
         } else {
             $node->addAttribute('class', 'uk-navbar-nav');
         }
     }
     if ($node->getName() == 'li') {
         $css = '';
         // parent
         if (isset($node->div)) {
             $css .= ' uk-parent';
             $node->addAttribute('data-uk-dropdown', '');
         }
         // add li css classes
         $node->attributes()->class = trim($node->attributes()->class . $css);
         // add a/span css classes
         $children = $node->children();
         if ($firstChild = $children[0]) {
             $firstChild->addAttribute('class', trim($firstChild->attributes()->class . $css));
         }
     }
     unset($node->attributes()->icon);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:_zlmenu.php

示例2: adapt

 public function adapt(SimpleXMLElement $atomNode)
 {
     switch ($atomNode->getName()) {
         case AtomNS::ENTRY_ELEMENT:
             return new ActivityEntryExtension($atomNode);
             break;
             //			case ActivityNS::OBJECT_TYPE_ELEMENT:
             //				return new SimpleActivityExtension($atomNode, ActivityNS::OBJECT_TYPE_ELEMENT);
             //				break;
             //			case ActivityNS::OBJECT_ELEMENT:
             //				return new ActivityObjectExtension($atomNode, ActivityNS::OBJECT_ELEMENT);
             //				break;
         //			case ActivityNS::OBJECT_TYPE_ELEMENT:
         //				return new SimpleActivityExtension($atomNode, ActivityNS::OBJECT_TYPE_ELEMENT);
         //				break;
         //			case ActivityNS::OBJECT_ELEMENT:
         //				return new ActivityObjectExtension($atomNode, ActivityNS::OBJECT_ELEMENT);
         //				break;
         case AtomNS::AUTHOR_ELEMENT:
             return new ActivityObjectExtension($atomNode, AtomNS::AUTHOR_ELEMENT);
             break;
         default:
             throw new ExtensionFactoryException('No Adaptor Available for ' . $atomNode->getName() . ' element!');
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:25,代码来源:ActivityExtensionFactory.php

示例3: processRopeRequest

 /**
  * Get ROPE data, run corresponding handler
  *
  * @param  string $request - incoming XML request
  * @return string
  * @throws Exception
  */
 public function processRopeRequest($request)
 {
     $this->_request = $request;
     try {
         $this->_request = new SimpleXMLElement(urldecode($request), LIBXML_NOCDATA);
         /**
          * Check type of request and call proper handler 
          */
         switch ($this->_request->getName()) {
             case 'tradoria_check_order':
                 $this->_orderNode = 'order';
                 $responseTag = 'tradoria_check_order_response';
                 $response = $this->_checkOrder();
                 break;
             case 'tradoria_order_process':
                 $this->_orderNode = 'cart';
                 $responseTag = 'tradoria_order_process_response';
                 $response = $this->_processOrder();
                 break;
             case 'tradoria_order_status':
                 $responseTag = 'tradoria_order_status_response';
                 $response = $this->_statusUpdate();
                 break;
             default:
                 /**
                  * Error - Unrecognized request 
                  */
                 $responseTag = 'unknown_error';
                 $response = false;
         }
     } catch (Exception $e) {
         return $this->prepareResponse(false);
     }
     return $this->prepareResponse($response, $responseTag);
 }
开发者ID:rakuten-deutschland,项目名称:checkout-oxid,代码行数:42,代码来源:rakuten_rope.php

示例4: contributeMetadataObject

 /**
  * @param SimpleXMLElement $mrss
  * @param SimpleXMLElement $metadata
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath)
 {
     $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']";
     $metadataObject = $mrss->addChild($metadata->getName());
     foreach ($metadata->attributes() as $attributeField => $attributeValue) {
         $metadataObject->addAttribute($attributeField, $attributeValue);
     }
     foreach ($metadata as $metadataField => $metadataValue) {
         if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) {
             $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath);
         } else {
             $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue));
             $itemXPath = $currentXPath . "/*[local-name()='{$metadataField}']";
             if ($mrssParams && is_array($mrssParams->getItemXpathsToExtend()) && in_array($itemXPath, $mrssParams->getItemXpathsToExtend())) {
                 $relatedEntry = entryPeer::retrieveByPK((string) $metadataValue);
                 if ($relatedEntry) {
                     $relatedItemField = $metadataObject->addChild($metadataField . '_item');
                     $recursionMrssParams = null;
                     if ($mrssParams) {
                         $recursionMrssParams = clone $mrssParams;
                         $recursionMrssParams->setItemXpathsToExtend(array());
                         // stop the recursion
                     }
                     $relatedEntryMrss = kMrssManager::getEntryMrssXml($relatedEntry, $relatedItemField, $recursionMrssParams);
                 }
             }
         }
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:35,代码来源:kMetadataMrssManager.php

示例5: unserializeXml

 /**
  * Unserialize SimpleXMLElement
  *
  * @param \SimpleXMLElement $element   Element to unserialize
  * @param string            $classHint Hint to which class unserialize
  *
  * @return mixed unserialized object
  */
 protected function unserializeXml(\SimpleXMLElement $element, $classHint = null)
 {
     if ($this->configValue("extractClassFrom", "tagName") == "tagName") {
         $elementClassHint = $element->getName();
     } else {
         $xsiAttrs = $element->attributes("http://www.w3.org/2001/XMLSchema-instance");
         if (!isset($xsiAttrs["type"])) {
             throw new \Exception("Element {$element->getName()} has no {http://www.w3.org/2001/XMLSchema-instance}type attribute");
         }
         $elementClassHint = $xsiAttrs["type"];
     }
     $mapperClass = $this->configValue("mapperClasses", []);
     if (isset($mapperClass[$elementClassHint])) {
         $className = $mapperClass[$elementClassHint];
     } else {
         $className = $classHint ? $classHint : rtrim($this->configValue("classesNamespace", ""), '\\') . '\\' . $elementClassHint;
     }
     if (!class_exists($className, true)) {
         throw new ClassNotFoundException("Class '{$className}' not found");
     }
     $classInstance = new $className();
     $this->checkNodes($element->attributes(), $className, $classInstance);
     $this->checkNodes($element->children(), $className, $classInstance);
     return $classInstance;
 }
开发者ID:prakdp,项目名称:XML,代码行数:33,代码来源:Serializer.php

示例6: adapt

 public function adapt($data, $data_is_url = false)
 {
     $domObj = new SimpleXMLElement($data, null, $data_is_url);
     $documentAdapter = $this->_adapterTable[$domObj->getName()];
     if (isset($documentAdapter)) {
         return new $documentAdapter($domObj);
     } else {
         throw new DocumentAdapterFactoryException("No document adapter available for " . $domObj->getName() . " document!!");
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:10,代码来源:AtomDocumentAdapterFactory.php

示例7: adapt

 public function adapt(SimpleXMLElement $atomNode)
 {
     switch ($atomNode->getName()) {
         case AtomNS::ENTRY_ELEMENT:
             return new ThreadingEntryExtension($atomNode);
             break;
         default:
             throw new ExtensionFactoryException('No Adaptor Available for ' . $atomNode->getName() . ' element!');
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:10,代码来源:ThreadingExtensionFactory.php

示例8: createProductResponse

 /**
  * @param \SimpleXMLElement $xmlElement
  * @return \BolOpenApi\Response\ProductResponse
  * @throws \BolOpenApi\Exception
  */
 public function createProductResponse(\SimpleXMLElement $xmlElement)
 {
     if ($xmlElement->getName() != 'ProductResponse') {
         throw new Exception('Invalid XML element, expected ProductResponse but got "' . $xmlElement->getName() . '"');
     }
     $productResponse = new ProductResponse();
     $productResponse->setSessionId((string) $xmlElement->SessionId);
     $productResponse->setProduct($this->modelFactory->createProduct($xmlElement->Product));
     return $productResponse;
 }
开发者ID:netvlies,项目名称:bol-openapi-php-sdk,代码行数:15,代码来源:ResponseFactory.php

示例9: doPrettyPrintXML

 private function doPrettyPrintXML(SimpleXMLElement $han, $prefix = "")
 {
     if (count($han->children()) < 1) {
         return $prefix . "&lt;" . $han->getName() . $this->doWarpAttributes($han->attributes()) . "&gt;" . $han . "&lt;/" . $han->getName() . "&gt;<br />";
     }
     $ret = $prefix . "&lt;" . $han->getName() . $this->doWarpAttributes($han->attributes()) . "&gt;<br />";
     foreach ($han->children() as $key => $child) {
         $ret .= $this->doPrettyPrintXML($child, $prefix . "    ");
     }
     $ret .= $prefix . "&lt;/" . $han->getName() . "&gt;<br />";
     return $ret;
 }
开发者ID:neelaryan,项目名称:mutillidae,代码行数:12,代码来源:XMLHandler.php

示例10: xml2array

function xml2array($xml)
{
    $xmla = array();
    $xml = new SimpleXMLElement($xml);
    if ($xml->getName()) {
        $xmla[$xml->getName()] = array();
        foreach ($xml->children() as $child) {
            $xmla[$xml->getName()][$child->getName()] = (string) $child;
        }
    }
    return $xmla;
}
开发者ID:amooma,项目名称:gs-voiceprompts,代码行数:12,代码来源:prompts2rest.php

示例11: prepareData

 /**
  * Prepare installed categories array
  */
 private function prepareData(\SimpleXMLElement $level)
 {
     if (strstr($level->getName(), 'level_')) {
         $attributes = $level->attributes();
         $level_number = (int) str_replace('level_', '', $level->getName());
         if (isset($this->categories_levels[$level_number])) {
             foreach ($this->categories_levels[$level_number] as $key => $category) {
                 $this->categories_levels[$level_number][$key]['tpl'] = (string) $attributes->template_name ? (string) $attributes->template_name : '';
             }
             $this->categoriesData[] = $this->categories_levels[$level_number];
         }
     }
 }
开发者ID:RandomUsernameHere,项目名称:megainfo-corporate-cms,代码行数:16,代码来源:DemodataCategoriestemplates.php

示例12: appendXMLElement

 /**
  * Add SimpleXMLElement code into a SimpleXMLElement
  * @param SimpleXMLElement $append
  */
 public function appendXMLElement(\SimpleXMLElement $append)
 {
     if (strlen(trim((string) $append)) == 0) {
         $xml = $this->addChild($append->getName());
         foreach ($append->children() as $child) {
             $xml->appendXMLElement($child);
         }
     } else {
         $xml = $this->addChild($append->getName(), (string) $append);
     }
     foreach ($append->attributes() as $n => $v) {
         $xml->addAttribute($n, $v);
     }
 }
开发者ID:spalax,项目名称:zf2-libs,代码行数:18,代码来源:SimpleXmlElement.php

示例13: contributeMetadataObject

 /**
  * @param SimpleXMLElement $mrss
  * @param SimpleXMLElement $metadata
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath)
 {
     $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']";
     $metadataObject = $mrss->addChild($metadata->getName());
     foreach ($metadata->attributes() as $attributeField => $attributeValue) {
         $metadataObject->addAttribute($attributeField, $attributeValue);
     }
     foreach ($metadata as $metadataField => $metadataValue) {
         if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) {
             $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath);
         } else {
             $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue));
         }
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:21,代码来源:kMetadataMrssManager.php

示例14: recreate_img_tag

 public function recreate_img_tag($tag)
 {
     // Supress SimpleXML errors
     libxml_use_internal_errors(TRUE);
     try {
         $x = new SimpleXMLElement($tag);
         // We only want to rebuild img tags
         if ($x->getName() == 'img') {
             // Get the attributes I'll use in the new tag
             $alt = (string) $x->attributes()->alt;
             $src = (string) $x->attributes()->src;
             $classes = (string) $x->attributes()->class;
             $class_segs = explode(' ', $classes);
             // All images have a source
             $img = '<img src="' . $src . '"';
             // If alt not empty, add it
             if (!empty($alt)) {
                 $img .= ' alt="' . $alt . '"';
             }
             // Only alignment classes are allowed
             $allowed_classes = array('alignleft', 'alignright', 'alignnone', 'aligncenter');
             if (in_array($class_segs[0], $allowed_classes)) {
                 $img .= ' class="' . $class_segs[0] . '"';
             }
             // Finish up the img tag
             $img .= ' />';
             return $img;
         }
     } catch (Exception $e) {
     }
     // Tag not an img, so just return it untouched
     return $tag;
 }
开发者ID:felipegenuino,项目名称:ProjetoHotsitesAltoQi,代码行数:33,代码来源:functions.php

示例15: foreach

 function __construct(SimpleXMLElement $node, $namespaces = null)
 {
     $this->__name = $node->getName();
     $this->__value = $node;
     if ($namespaces === null) {
         $namespaces = $node->getNamespaces(true);
     }
     foreach ($namespaces as $ns => $uri) {
         foreach ($node->children($uri) as $child) {
             $childName = $ns ? "{$ns}:" . $child->getName() : $child->getName();
             if (array_key_exists($childName, $this->__children) && is_array($this->__children[$childName])) {
                 $this->__children[$childName][] = new clNode($child, $namespaces);
             } else {
                 if (array_key_exists($childName, $this->__children) && get_class($this->__children[$childName]) == "clNode") {
                     $childArray = array();
                     $childArray[] = $this->__children[$childName];
                     $childArray[] = new clNode($child, $namespaces);
                     $this->__children[$childName] = $childArray;
                 } else {
                     $this->__children[$childName] = new clNode($child, $namespaces);
                 }
             }
         }
         foreach ($node->attributes($ns) as $a) {
             $a = $a->asXML();
             @(list($name, $value) = split('=', $a));
             $this->__attributes[trim($name)] = substr($value, 1, strlen($value) - 2);
         }
     }
 }
开发者ID:stereoket,项目名称:coreylib,代码行数:30,代码来源:index.php


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