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


PHP SimpleXMLElement::attributes方法代码示例

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


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

示例1: __construct

 public function __construct($input)
 {
     $sxe = new \SimpleXMLElement($input);
     $this->evec_method = (string) $sxe->attributes()->method;
     $this->evec_version = (string) $sxe->attributes()->version;
     foreach ($sxe->marketstat->type as $t) {
         $id = (int) $t->attributes()->id;
         $this->types[$id] = new \stdClass();
         $this->types[$id]->buy = new \stdClass();
         $this->types[$id]->buy->volume = (double) $t->buy->volume;
         $this->types[$id]->buy->avg = (double) $t->buy->avg;
         $this->types[$id]->buy->max = (double) $t->buy->max;
         $this->types[$id]->buy->min = (double) $t->buy->min;
         $this->types[$id]->buy->stddev = (double) $t->buy->stddev;
         $this->types[$id]->buy->median = (double) $t->buy->median;
         $this->types[$id]->buy->percentile = (double) $t->buy->percentile;
         $this->types[$id]->sell = new \stdClass();
         $this->types[$id]->sell->volume = (double) $t->sell->volume;
         $this->types[$id]->sell->avg = (double) $t->sell->avg;
         $this->types[$id]->sell->max = (double) $t->sell->max;
         $this->types[$id]->sell->min = (double) $t->sell->min;
         $this->types[$id]->sell->stddev = (double) $t->sell->stddev;
         $this->types[$id]->sell->median = (double) $t->sell->median;
         $this->types[$id]->sell->percentile = (double) $t->sell->percentile;
         $this->types[$id]->all = new \stdClass();
         $this->types[$id]->all->volume = (double) $t->all->volume;
         $this->types[$id]->all->avg = (double) $t->all->avg;
         $this->types[$id]->all->max = (double) $t->all->max;
         $this->types[$id]->all->min = (double) $t->all->min;
         $this->types[$id]->all->stddev = (double) $t->all->stddev;
         $this->types[$id]->all->median = (double) $t->all->median;
         $this->types[$id]->all->percentile = (double) $t->all->percentile;
     }
 }
开发者ID:afarazit,项目名称:phpevecentral,代码行数:34,代码来源:MarketStat.php

示例2: 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

示例3: createFromResponse

 public static function createFromResponse(\SimpleXMLElement $response)
 {
     $chart = new Chart();
     $chart->setFrom((int) $response->attributes()->from);
     $chart->setTo((int) $response->attributes()->to);
     return $chart;
 }
开发者ID:kyaroslav,项目名称:BinaryThinkingLastfmBundle,代码行数:7,代码来源:Chart.php

示例4: parse

 /**
  * Parses a simple xml element and returns an executable string for a layout node
  *
  * @param SimpleXMLElement $element
  * @param \EcomDev_LayoutCompiler_Contract_CompilerInterface $compiler
  * @param null|string $blockIdentifier
  * @param string[] $parentIdentifiers
  * @return string|string[]
  */
 public function parse(SimpleXMLElement $element, \EcomDev_LayoutCompiler_Contract_CompilerInterface $compiler, $blockIdentifier = null, $parentIdentifiers = array())
 {
     if (empty($element->attributes()->name)) {
         return false;
     }
     return $this->getClassStatement(array((string) $element->attributes()->name));
 }
开发者ID:albertobraschi,项目名称:EcomDev_LayoutCompiler,代码行数:16,代码来源:Remove.php

示例5: xml2js

 private function xml2js(SimpleXMLElement $xmlnode, $isRoot = true)
 {
     $jsnode = array();
     if (!$isRoot) {
         if (count($xmlnode->attributes()) > 0) {
             $jsnode["@attribute"] = array();
             foreach ($xmlnode->attributes() as $key => $value) {
                 $jsnode["@attribute"][$key] = (string) $value;
             }
         }
         $textcontent = trim((string) $xmlnode);
         if (count($textcontent) > 0) {
             $jsnode['_'] = $textcontent;
         }
         foreach ($xmlnode->children() as $childxmlnode) {
             $childname = $childxmlnode->getName();
             if (!array_key_exists($childname, $jsnode)) {
                 $jsnode[$childname] = array();
             }
             array_push($jsnode[$childname], $this->xml2js($childxmlnode, false));
         }
         return $jsnode;
     } else {
         $nodename = $xmlnode->getName();
         $jsnode[$nodename] = array();
         array_push($jsnode[$nodename], $this->xml2js($xmlnode, false));
         return json_encode($jsnode, JSON_PRETTY_PRINT);
     }
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:29,代码来源:JsonLogger.php

示例6: 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

示例7: loadLanguage

 /**
  * Custom loadLanguage method
  *
  * @param   string  $path  The path where to find language files.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function loadLanguage($path = null)
 {
     $source = $this->parent->getPath('source');
     if (!$source) {
         $this->parent->setPath('source', JPATH_PLUGINS . '/' . $this->parent->extension->folder . '/' . $this->parent->extension->element);
     }
     $this->manifest = $this->parent->getManifest();
     $element = $this->manifest->files;
     if ($element) {
         $group = strtolower((string) $this->manifest->attributes()->group);
         $name = '';
         if (count($element->children())) {
             foreach ($element->children() as $file) {
                 if ((string) $file->attributes()->plugin) {
                     $name = strtolower((string) $file->attributes()->plugin);
                     break;
                 }
             }
         }
         if ($name) {
             $extension = "plg_{$group}_{$name}";
             $lang = JFactory::getLanguage();
             $source = $path ? $path : JPATH_PLUGINS . "/{$group}/{$name}";
             $folder = (string) $element->attributes()->folder;
             if ($folder && file_exists("{$path}/{$folder}")) {
                 $source = "{$path}/{$folder}";
             }
             $lang->load($extension . '.sys', $source, null, false, true) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true);
         }
     }
 }
开发者ID:woakes070048,项目名称:joomlatools-platform,代码行数:40,代码来源:plugin.php

示例8: 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

示例9: getStatus

 /**
  * Returns the response status (OK = success, ERROR = error, null = invalid responses)
  *
  * @return string NULL
  */
 public function getStatus()
 {
     if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
         return (string) $this->xml->attributes()->Status;
     }
     return null;
 }
开发者ID:modernmedia,项目名称:Namecheap,代码行数:12,代码来源:Response.php

示例10: parse

 /**
  * Parses a simple xml element and returns an executable string for a layout node
  *
  * @param SimpleXMLElement $element
  * @param \EcomDev_LayoutCompiler_Contract_CompilerInterface $compiler
  * @param null|string $blockIdentifier
  * @param string[] $parentIdentifiers
  * @return string|string[]
  */
 public function parse(SimpleXMLElement $element, CompilerInterface $compiler, $blockIdentifier = null, $parentIdentifiers = array())
 {
     if ($blockIdentifier !== null && !in_array($blockIdentifier, $parentIdentifiers, true)) {
         $parentIdentifiers[] = $blockIdentifier;
     }
     $blockIdentifier = isset($element->attributes()->{$this->idAttribute}) ? (string) $element->attributes()->{$this->idAttribute} : null;
     return $compiler->parseElements($element, $blockIdentifier, $parentIdentifiers);
 }
开发者ID:albertobraschi,项目名称:EcomDev_LayoutCompiler,代码行数:17,代码来源:Reference.php

示例11: getBootstrap

 /**
  * Get the bootstrap PHPUnit configuration attribute
  *
  * @return string The bootstrap attribute or empty string if not set
  */
 public function getBootstrap()
 {
     if ($this->xml) {
         return (string) $this->xml->attributes()->bootstrap;
     } else {
         return '';
     }
 }
开发者ID:brianium,项目名称:paratest,代码行数:13,代码来源:Configuration.php

示例12: getAttributes

 protected function getAttributes(\SimpleXMLElement $node)
 {
     if (count($node->attributes()) > 0) {
         $attr = (array) $node->attributes();
         return $attr['@attributes'];
     }
     return array();
 }
开发者ID:Kinetical,项目名称:Kinesis,代码行数:8,代码来源:Node.php

示例13: __construct

 /**
  * @param \SimpleXMLElement $node
  */
 public function __construct(\SimpleXMLElement $node)
 {
     $this->node = $node;
     $attrs = $this->node->attributes();
     $this->name = (string) $attrs['name'];
     $this->type = (string) $attrs['type'];
     $this->relation = (string) $attrs['relation'];
 }
开发者ID:RandomUsernameHere,项目名称:megainfo-corporate-cms,代码行数:11,代码来源:DependenceBase.php

示例14: __construct

 public function __construct(\SimpleXMLElement $object)
 {
     $this->setURL((string) $object->attributes()->url);
     $this->setData((string) $object);
     $this->setFileName((string) $object->attributes()->file);
     $this->setOrdering((string) $object->attributes()->id);
     $this->setModified((string) $object->attributes()->modTime);
     $this->setFiletype((string) $object->attributes()->format);
 }
开发者ID:thinkerytim,项目名称:thinkery-reaxml-parser,代码行数:9,代码来源:MediaMember.php

示例15: createFromXML

 /**
  * Convert the raw XML into an object
  *
  * @param \SimpleXMLElement $xml
  * @return Mail
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $mail = new Mail();
     if (isset($xml->attributes()['type'])) {
         $mail->setType((string) $xml->attributes()['type']);
     }
     $mail->setValue((string) $xml);
     return $mail;
 }
开发者ID:tijsverkoyen,项目名称:uitdatabank,代码行数:15,代码来源:Mail.php


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