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


PHP XMLReader::moveToAttributeNo方法代码示例

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


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

示例1: readDump

 function readDump()
 {
     $state = '';
     $lastName = '';
     $this->thisPage = 0;
     $this->thisRev = 0;
     $reader = new XMLReader();
     $reader->open($this->input);
     $writer = new XMLWriter();
     $writer->openMemory();
     while ($reader->read()) {
         $tag = $reader->name;
         $type = $reader->nodeType;
         if ($type == XmlReader::END_ELEMENT) {
             $writer->endElement();
             if ($tag == 'revision') {
                 $this->revCount();
                 $this->thisRev = '';
             } elseif ($tag == 'page') {
                 $this->reportPage();
                 $this->thisPage = '';
             }
         } elseif ($type == XmlReader::ELEMENT) {
             $attribs = array();
             if ($reader->hasAttributes) {
                 for ($i = 0; $reader->moveToAttributeNo($i); $i++) {
                     $attribs[$reader->name] = $reader->value;
                 }
             }
             if ($reader->isEmptyElement && $tag == 'text' && isset($attribs['id'])) {
                 $writer->startElement('text');
                 $writer->writeAttribute('xml:space', 'preserve');
                 $text = $this->getText($attribs['id']);
                 if (strlen($text)) {
                     $writer->text($text);
                 }
                 $writer->endElement();
             } else {
                 $writer->startElement($tag);
                 foreach ($attribs as $name => $val) {
                     $writer->writeAttribute($name, $val);
                 }
                 if ($reader->isEmptyElement) {
                     $writer->endElement();
                 }
             }
             $lastName = $tag;
             if ($tag == 'revision') {
                 $state = 'revision';
             } elseif ($tag == 'page') {
                 $state = 'page';
             }
         } elseif ($type == XMLReader::SIGNIFICANT_WHITESPACE || ($type = XMLReader::TEXT)) {
             if ($lastName == 'id') {
                 if ($state == 'revision') {
                     $this->thisRev .= $reader->value;
                 } elseif ($state == 'page') {
                     $this->thisPage .= $reader->value;
                 }
             }
             $writer->text($reader->value);
         }
         $this->sink->write($writer->outputMemory());
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:65,代码来源:dumpTextPass.php

示例2:

            }
            // Named attribute
            $attr = $reader->moveToAttribute('num');
            echo $reader->name . ": ";
            echo $reader->value . "\n";
            if ($reader->getAttribute('num') == $reader->value) {
                echo "attr num failed\n";
            }
            $attr = $reader->moveToAttribute('idx');
            echo $reader->name . ": ";
            echo $reader->value . "\n";
            if ($reader->getAttribute('idx') == $reader->value) {
                echo "attr idx failed\n";
            }
            // Numeric positions of attributes
            $attr = $reader->moveToAttributeNo(0);
            echo $reader->name . ": ";
            echo $reader->value . "\n";
            if ($reader->getAttributeNo(0) == $reader->value) {
                echo "attr 0 failed\n";
            }
            $attr = $reader->moveToAttributeNo(1);
            echo $reader->name . ": ";
            echo $reader->value . "\n";
        }
    }
}
$reader->close();
unlink($filename);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:003.php

示例3: while

     while ($owl->nodeType != XMLReader::END_ELEMENT || $owl->name != "owl:Ontology") {
         if ($owl->nodeType == XMLReader::ELEMENT) {
             // This is the switch statement below that can be written instead of the if logic statement for foaf:homepage
             // It determines the specific name of the element
             switch ($owl->name) {
                 case 'foaf:homepage':
                     break;
                 case 'dc:title':
                     break;
                 case 'dc:description':
                     break;
             }
         }
         if ($owl->name == "foaf:homepage" && $owl->nodeType == XMLReader::ELEMENT) {
             for ($n = 0; $n < $owl->attributeCount; $n++) {
                 $owl->moveToAttributeNo($n);
                 print $owl->name . ' = "' . $owl->value . "\"\n";
             }
             $owl->read();
             print $owl->value . "\n";
         }
         $owl->read();
     }
 }
 if ($owl->nodeType == XMLReader::ELEMENT && $owl->name == "rdf:Description") {
     while ($owl->nodeType != XMLReader::END_ELEMENT || $owl->name != "rdf:Description") {
         if ($owl->nodeType == XMLReader::ELEMENT) {
             print "ELEMENT" . $owl->name . "\n";
             if ($owl->hasAttributes && $owl->nodeType == XMLReader::ELEMENT) {
                 for ($n = 0; $n < $owl->attributeCount; $n++) {
                     $owl->moveToFirstAttribute();
开发者ID:spficklin,项目名称:OWL-XML-parser-into-Chado,代码行数:31,代码来源:joshhelp_parser.php

示例4: moveToAttributeNo

 public function moveToAttributeNo($index)
 {
     return parent::moveToAttributeNo($index);
 }
开发者ID:philip,项目名称:phd,代码行数:4,代码来源:Reader.php


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