當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。