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


PHP SimpleXMLIterator::next方法代码示例

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


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

示例1: next

 function next()
 {
     $this->it_actual->next();
     if (!$this->it_actual->valid()) {
         $this->it_actual = $this->get_siguiente_iterador_valido();
     }
 }
开发者ID:emma5021,项目名称:toba,代码行数:7,代码来源:toba_importador_plan.php

示例2: __construct

 /**
  * Create the ResultSet
  *
  * @param  object $result
  * @return void
  */
 public function __construct($result)
 {
     $xmlIterator = new \SimpleXMLIterator($result);
     for ($xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next()) {
         $temp = new \stdClass();
         foreach ($xmlIterator->getChildren()->attributes() as $name => $value) {
             switch ($name) {
                 case 'orderId':
                 case 'brokerTicketId':
                 case 'quantity':
                 case 'purchaseOrderId':
                     $temp->{$name} = (int) $value;
                     break;
                 case 'cost':
                     $temp->{$name} = (double) $value;
                     break;
                 case 'electronicDelivery':
                     $temp->{$name} = (bool) $value;
                     break;
                 default:
                     $temp->{$name} = (string) $value;
             }
         }
         $this->_results[] = $temp;
     }
     unset($xmlIterator, $temp, $name, $value);
 }
开发者ID:teamonetickets,项目名称:razorgator-php,代码行数:33,代码来源:AbstractResultSet.php

示例3: xmlToArray

 private function xmlToArray(\SimpleXMLIterator $sxi)
 {
     $a = array();
     for ($sxi->rewind(); $sxi->valid(); $sxi->next()) {
         $t = array();
         $current = $sxi->current();
         $attributes = $current->attributes();
         $name = isset($attributes->_key) ? strval($attributes->_key) : $sxi->key();
         // save attributes
         foreach ($attributes as $att_key => $att_value) {
             if ($att_key !== '_key') {
                 $t[$att_key] = strval($att_value);
             }
         }
         // we parse nodes
         if ($sxi->hasChildren()) {
             // children
             $t = array_merge($t, $this->xmlToArray($current));
         } else {
             // it's a leaf
             if (empty($t)) {
                 $t = strval($current);
                 // strval will call _toString()
             } else {
                 $t['_value'] = strval($current);
                 // strval will call _toString()
             }
         }
         $a[$name] = $t;
     }
     return $a;
 }
开发者ID:romaricdrigon,项目名称:metayaml,代码行数:32,代码来源:XmlLoader.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileInfo = new \SplFileInfo($this->getContainer()->getParameter('kernel.root_dir') . '/../web/sitemap.xml');
     if ($fileInfo->isFile() && $fileInfo->isReadable()) {
         $output->write('Reading sitemap.xml...');
         $file = $fileInfo->openFile();
         $xml = '';
         while (!$file->eof()) {
             $xml .= $file->fgets();
         }
         $output->writeln(' done.');
         $output->write('Updating sitemap.xml...');
         $sitemap = new \SimpleXMLIterator($xml);
         $sitemap->rewind();
         $lastmodDate = new \DateTime();
         $lastmodDate->sub(new \DateInterval('P1D'));
         $lastmodDateFormatted = $lastmodDate->format('Y-m-d');
         while ($sitemap->valid()) {
             $sitemap->current()->lastmod = $lastmodDateFormatted;
             $sitemap->next();
         }
         $file = $file->openFile('w');
         $file->fwrite($sitemap->asXML());
         $output->writeln(' done.');
     } else {
         $output->writeln('Error: Cannot open file web/sitemap.xml');
     }
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:28,代码来源:UpdateSitemapCommand.php

示例5: get_elements_from_supplied_file

function get_elements_from_supplied_file($file)
{
    $found_elements = array();
    if ($xml = file_get_contents($file)) {
        //print_r($xml);
        //SimpleXMLIterator just runs over the xml and returns the elements found in this file. I think this is just top level
        //which is what I want.
        //echo $xml;
        /* Some safety against XML Injection attack
         * see: http://phpsecurity.readthedocs.org/en/latest/Injection-Attacks.html
         * 
         * Attempt a quickie detection of DOCTYPE - discard if it is present (cos it shouldn't be!)
         */
        $collapsedXML = preg_replace("/[[:space:]]/", '', $xml);
        //echo $collapsedXML;
        if (preg_match("/<!DOCTYPE/i", $collapsedXML)) {
            //throw new InvalidArgumentException(
            //     'Invalid XML: Detected use of illegal DOCTYPE'
            // );
            //echo "fail";
            return FALSE;
        }
        $loadEntities = libxml_disable_entity_loader(true);
        $dom = new DOMDocument();
        $dom->loadXML($xml);
        foreach ($dom->childNodes as $child) {
            if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
                throw new Exception\ValueException('Invalid XML: Detected use of illegal DOCTYPE');
                libxml_disable_entity_loader($loadEntities);
                return FALSE;
            }
        }
        libxml_disable_entity_loader($loadEntities);
        //Iterate over elements now
        if (simplexml_import_dom($dom)) {
            $xmlIterator = new SimpleXMLIterator($xml);
            for ($xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next()) {
                foreach ($xmlIterator->getChildren() as $name => $data) {
                    //echo "The $name is '$data' from the class " . get_class($data) . "\n";
                    $found_elements[] = $name;
                }
            }
        } else {
            return FALSE;
        }
    }
    return $found_elements;
}
开发者ID:rolfkleef,项目名称:IATI-Public-Validator,代码行数:48,代码来源:get_elements_from_supplied_file.php

示例6: parseDependencyType

 protected function parseDependencyType(\SimpleXMLIterator $iterator, DependencyCollection $dependencies, $required = true)
 {
     $iterator->rewind();
     while ($iterator->valid()) {
         $elt = $iterator->current();
         $name = $elt->getName();
         $iterator->next();
         if ($name === 'php') {
             $dependencies->import($this->parsePhpCondition($elt));
         } elseif ($name === 'pearinstaller') {
             // Let's just ignore this for now!
         } else {
             // TODO do not ignore recommended, nodefault and uri, providesextension
             $identifier = 'pear2://' . (string) $elt->channel . '/' . (string) $elt->name;
             $dependencies[] = new Dependency($identifier, isset($elt->min) ? (string) $elt->min : null, isset($elt->max) ? (string) $elt->max : null, isset($elt->conflicts) ? Dependency::CONFLICT : ($required ? Dependency::REQUIRED : Dependency::OPTIONAL));
             foreach ($elt->exclude as $exclude) {
                 $dependencies[] = new Dependency($identifier, (string) $exclude, (string) $exclude, Dependency::CONFLICT);
             }
         }
     }
 }
开发者ID:rosstuck,项目名称:Pok,代码行数:21,代码来源:Loader.php

示例7: SimpleXMLIterator

<pre>
<?php 
$xml = <<<XML
<books>
    <book>
        <title>PHP Basics</title>
        <author>Jim Smith</author>
    </book>
    <book>XML basics</book>
</books>
XML;
$xmlIterator = new SimpleXMLIterator($xml);
//books
for ($xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next()) {
    foreach ($xmlIterator->getChildren() as $name => $data) {
        echo "The {$name} is '{$data}' from the class " . get_class($data) . "\n";
    }
    echo $xmlIterator->getName() . "\n";
    //2 times of books will be print out
}
?>
</pre>
开发者ID:pixlr,项目名称:zce-1,代码行数:22,代码来源:getChildren.php

示例8: strval

                        case "file_name":
                            $filename = strval($props->current());
                    }
                    $props->next();
                }
                if (!empty($fileid) && !empty($filename)) {
                    $contents = get_file_contents($fileid);
                    if ($contents) {
                        parse_file($filename, $contents);
                    }
                }
            }
            $rows->next();
        }
    }
    $xml->next();
}
$lastchange = intval(ConfigHelper::getConfig('finances.bgz_password_lastchange', 0));
if (!$lastchange || time() - $lastchange > 30 * 86400) {
    if (!$quiet) {
        printf("Changing BGZ password ... ");
    }
    $oldpass = ConfigHelper::getConfig('finances.bgz_password');
    $newpassarray = str_split($oldpass);
    array_unshift($newpassarray, array_pop($newpassarray));
    $newpass = implode('', $newpassarray);
    $res = change_password($oldpass, $newpass);
    if ($res) {
        $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'finances' AND var = 'bgz_password'", array($newpass));
        $DB->Execute("DELETE FROM uiconfig WHERE section = 'finances' AND var = 'bgz_password_lastchange'");
        $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('finances', 'bgz_password_lastchange', ?NOW?)");
开发者ID:Akheon23,项目名称:lms,代码行数:31,代码来源:lms-cashimport-bgz.php

示例9: parse

 /**
  * Parses object. Turns raw XML(NPRML) into various object properties.
  */
 function parse()
 {
     if (!empty($this->xml)) {
         $xml = $this->xml;
     } else {
         $this->notices[] = 'No XML to parse.';
         return;
     }
     $object = simplexml_load_string($xml);
     $this->add_simplexml_attributes($object, $this);
     if (!empty($object->message)) {
         $this->message->id = $this->get_attribute($object->message, 'id');
         $this->message->level = $this->get_attribute($object->message, 'level');
     }
     if (!empty($object->list->story)) {
         foreach ($object->list->story as $story) {
             $parsed = new NPRMLEntity();
             $this->add_simplexml_attributes($story, $parsed);
             //Iterate trough the XML document and list all the children
             $xml_iterator = new SimpleXMLIterator($story->asXML());
             $key = NULL;
             $current = NULL;
             for ($xml_iterator->rewind(); $xml_iterator->valid(); $xml_iterator->next()) {
                 $current = $xml_iterator->current();
                 $key = $xml_iterator->key();
                 if ($key == 'image' || $key == 'audio' || $key == 'link') {
                     // images
                     if ($key == 'image') {
                         $parsed->{$key}[] = $this->parse_simplexml_element($current);
                     }
                     // audio
                     if ($key == 'audio') {
                         $parsed->{$key}[] = $this->parse_simplexml_element($current);
                     }
                     // links
                     if ($key == 'link') {
                         $type = $this->get_attribute($current, 'type');
                         $parsed->{$key}[$type] = $this->parse_simplexml_element($current);
                     }
                 } else {
                     //if ->$key exist, see if it's an array.  if it is, add the next child.
                     if (!empty($parsed->{$key})) {
                         //if it's not an array, make an array, add the existing element to it
                         if (!is_array($parsed->{$key})) {
                             $parsed->{$key} = array($parsed->{$key});
                         }
                         // then add the new child.
                         $parsed->{$key}[] = $this->parse_simplexml_element($current);
                     } else {
                         //The key wasn't parsed already, so just add the current element.
                         $parsed->{$key} = $this->parse_simplexml_element($current);
                     }
                 }
             }
             $body = '';
             if (!empty($parsed->textWithHtml->paragraphs)) {
                 foreach ($parsed->textWithHtml->paragraphs as $paragraph) {
                     $body = $body . $paragraph->value . "\n\n";
                 }
             }
             $parsed->body = $body;
             $this->stories[] = $parsed;
         }
         //if the query didn't have a sort parameter, reverse the order so that we end up with
         //stories in reverse-chron order.
         //there are no params and 'sort=' is not in the URL
         if (empty($this->request->params) && !stristr($this->request->request_url, 'sort=')) {
             $this->stories = array_reverse($this->stories);
         }
         //there are params, and sort is not one of them
         if (!empty($this->request->params) && !array_key_exists('sort', $this->request->params)) {
             $this->stories = array_reverse($this->stories);
         }
     }
 }
开发者ID:nprds,项目名称:nprapi-wordpress,代码行数:78,代码来源:NPRAPI.php

示例10: next

 function next()
 {
     echo __METHOD__ . "\n";
     return parent::next();
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:sxe_004.php

示例11: find

 /**
  *
  * Realiza busca no xmlRoot pelas referências de arquivo
  * @return \stdClass
  */
 public function find()
 {
     $get = self::$_config['attrs']->src->root;
     $xmlIterator = new SimpleXMLIterator(self::$_config['valueObject']->get());
     $references = "";
     for ($xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next()) {
         foreach ($xmlIterator->getChildren() as $name => $data) {
             $references .= '<reference>' . $data . '</reference>';
         }
     }
     $result = new \stdClass();
     $result->references = $references;
     return $result;
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:19,代码来源:Tamburete.php

示例12: var_dump

<pre>
<?php 
$xmlIterator = new SimpleXMLIterator('<books><book>SQL Basics</book></books>');
$xmlIterator->rewind();
// rewind to the first element
echo var_dump($xmlIterator->valid());
// bool(true)
$xmlIterator->next();
// advance to the next element
echo var_dump($xmlIterator->valid());
// bool(false) because there is only one element
?>
</pre>
开发者ID:pixlr,项目名称:zce-1,代码行数:13,代码来源:valid.php

示例13: sxiToArray

 /**
  * @param SimpleXMLIterator $sxi
  */
 public function sxiToArray($sxi)
 {
     $a = array();
     for ($sxi->rewind(); $sxi->valid(); $sxi->next()) {
         if (!array_key_exists($sxi->key(), $a)) {
             $a[$sxi->key()] = array();
         }
         if ($sxi->hasChildren()) {
             $a[$sxi->key()]['children'] = $this->sxiToArray($sxi->current());
         } else {
             $a[$sxi->key()][] = strval($sxi->current());
         }
     }
     return $a;
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:18,代码来源:admin.acctexp.class.php

示例14: SimpleXMLIterator

    $simpleIt = new SimpleXMLIterator($xmlString);
    // 循环所有的节点
    foreach (new RecursiveIteratorIterator($simpleIt, 1) as $name => $data) {
        //echo $name, '=>', $data, "<br />";
    }
    // while 循环
    $simpleIt->rewind();
    while ($simpleIt->valid()) {
        /*var_dump($simpleIt->key());
          echo '=>';
          var_dump($simpleIt->current());*/
        // getChildren() 获得当前节点的子节点
        if ($simpleIt->hasChildren()) {
            //var_dump($simpleIt->getChildren());
        }
        $simpleIt->next();
    }
    // xpath 可以通过path直接获得指定节点的值
    var_dump($simpleIt->xpath('animal/category/species'));
} catch (Exception $e) {
    echo $e->getMessage();
}
echo '--------------------------------- SimpleXMLIterator END-----------------------------------', '<br />';
echo '--------------------------------- CachingIterator START-----------------------------------', '<br />';
/**
 * CachingIterator 提前读取一个元素
 * 可以用于确定当前元素是否为最后一个元素
 */
$array = array('koala', 'kangaroo', 'wombat', 'wallaby', 'emu', 'kiwi', 'kookaburra', 'platypus');
try {
    $cachingIt = new CachingIterator(new ArrayIterator($array));
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:iterator.php

示例15: ParseXML

 private function ParseXML($data_content)
 {
     $xmlIterator = new SimpleXMLIterator($data_content);
     $xmlIterator->rewind();
     $xmlIterator->next();
     while ($xmlIterator->current() != Null) {
         $current = $xmlIterator->current();
         $Item = $this->ParsePerItem($current);
         $Parsed[$Item["sku"]] = $Item;
         $xmlIterator->next();
     }
     return $Parsed;
 }
开发者ID:blaz1988,项目名称:presta,代码行数:13,代码来源:uploadxml.php


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