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


PHP XMLReader::moveToElement方法代码示例

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


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

示例1: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     if (!is_file($filename)) {
         v("Can't find Version information file (%s), skipping!", $filename, E_USER_WARNING);
         return array();
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         v("Can't open the version info file (%s)", $filename, E_USER_ERROR);
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("-", "-", "-", "-", ""), $r->value)) && $r->moveToAttribute("from") && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:robertop,项目名称:phd,代码行数:25,代码来源:XHTML.php

示例2: writeReaderImpl

 private function writeReaderImpl(XMLWriter $writer, XMLReader $reader)
 {
     switch ($reader->nodeType) {
         case XMLReader::ELEMENT:
             $writer->startElement($reader->name);
             if ($reader->moveToFirstAttribute()) {
                 do {
                     $writer->writeAttribute($reader->name, $reader->value);
                 } while ($reader->moveToNextAttribute());
                 $reader->moveToElement();
             }
             if ($reader->isEmptyElement) {
                 $writer->endElement();
             }
             break;
         case XMLReader::END_ELEMENT:
             $writer->endElement();
             break;
         case XMLReader::COMMENT:
             $writer->writeComment($reader->value);
             break;
         case XMLReader::SIGNIFICANT_WHITESPACE:
         case XMLReader::TEXT:
             $writer->text($reader->value);
             break;
         case XMLReader::PI:
             $writer->writePi($reader->name, $reader->value);
             break;
         default:
             XMLReaderNode::dump($reader);
     }
 }
开发者ID:hakre,项目名称:xmlreaderiterator,代码行数:32,代码来源:XMLWritingIteration.php

示例3: parse

 public function parse(\XMLReader $xmlReader, $startingDepth = 0, $parseOne = false)
 {
     if ($this->callback !== null) {
         $node = new Node();
         $node->name = $xmlReader->name;
         $node->depth = $xmlReader->depth;
         $node->text = $xmlReader->readString();
         if ($xmlReader->hasAttributes && $xmlReader->moveToFirstAttribute()) {
             do {
                 $node->attributes[$xmlReader->name] = $xmlReader->value;
             } while ($xmlReader->moveToNextAttribute());
             $xmlReader->moveToElement();
         }
         $callback = $this->callback;
         $callback($this->processNode($node, $xmlReader));
     }
 }
开发者ID:rhubarbphp,项目名称:rhubarb,代码行数:17,代码来源:NodeStrategyRead.php

示例4: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         throw new \Exception("Could not open file for accessing version information: {$filename}");
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("-", "-", "-", "-", ""), $r->value)) && $r->moveToAttribute("from") && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:philip,项目名称:phd,代码行数:21,代码来源:XHTML.php

示例5: getAttributes

 /**
  * Returns the given node's attributes as an associative array
  *
  * @param \XMLReader $reader
  *
  * @return array
  */
 protected function getAttributes(\XMLReader $reader)
 {
     if (!$reader->hasAttributes) {
         return array();
     }
     $attributes = array();
     $reader->moveToFirstAttribute();
     do {
         $attributes[($reader->prefix ? $reader->prefix . ':' : '') . $reader->localName] = $reader->value;
     } while ($reader->moveToNextAttribute());
     $reader->moveToElement();
     return $attributes;
 }
开发者ID:bluem,项目名称:xmltransformer,代码行数:20,代码来源:XMLTransformer.php

示例6: traverse

 /**
  * Traverse XML tree
  *
  * Traverses the XML tree and calls the learnAutomaton() method for each 
  * element, with its child element nodes.
  * 
  * @param DOMNode $root 
  * @return void
  */
 protected function traverse(XMLReader $reader, $path = array())
 {
     $contents = array();
     $whitespace = array();
     $children = array();
     $attributes = array();
     // Learn attributes for this element
     while ($reader->moveToNextAttribute()) {
         $attributes[$reader->name] = $reader->value;
     }
     $reader->moveToElement();
     // If this is an empty element, do not traverse, but return
     // immediately.
     if ($reader->nodeType === XMLReader::ELEMENT && $reader->isEmptyElement) {
         $element = $this->getType($path);
         $this->learnAutomaton($element, $children);
         $this->learnSimpleType($element, $contents);
         $this->learnAttributes($element, $attributes);
         return;
     }
     // Traverse child elements.
     while ($reader->read()) {
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 // Opening tag
                 $child = array('namespace' => $reader->namespaceURI, 'name' => $reader->localName, 'parents' => $path);
                 $children[] = $child;
                 $childPath = array_merge($path, array($child));
                 // If we are in the document root, add the child as root
                 // element.
                 if (count($path) === 0) {
                     $this->rootElements[$child['name']] = $this->inferenceType($childPath);
                 }
                 $this->traverse($reader, $childPath);
                 break;
             case XMLReader::END_ELEMENT:
                 // Closing tag
                 $element = $this->getType($path);
                 if (!count($children)) {
                     // Significant whitespace seems only significant if
                     // there are children, but there is still some
                     // whitespace.
                     $contents = array_merge($contents, $whitespace);
                 }
                 $this->learnAutomaton($element, $children);
                 $this->learnSimpleType($element, $contents);
                 $this->learnAttributes($element, $attributes);
                 return;
             case XMLReader::TEXT:
             case XMLReader::CDATA:
                 // Text content
                 $contents[] = $reader->value;
                 break;
             case XMLReader::SIGNIFICANT_WHITESPACE:
                 $whitespace[] = $reader->value;
                 break;
         }
     }
 }
开发者ID:kore,项目名称:XML-Schema-learner,代码行数:68,代码来源:schema.php

示例7: getAttributes

 private function getAttributes(XMLReader $xml, $attrsLists = 'all')
 {
     $attrs = array();
     if (is_array($attrsLists)) {
         foreach ($attrsLists as $attr) {
             $attrs[$attr] = $xml->getAttribute($attr);
         }
     } else {
         if ($attrsLists == 'all') {
             while ($xml->moveToNextAttribute()) {
                 $attrs[$xml->name] = $xml->value;
             }
         }
     }
     // return the reader to the original Element
     $xml->moveToElement();
     return $attrs;
 }
开发者ID:rebe100x,项目名称:YAKREP,代码行数:18,代码来源:XMLV10Parser.php

示例8: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         throw new \Exception();
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute('name') && ($funcname = str_replace(array('::', '->', '__', '_', '$'), array('-', '-', '-', '-', ''), $r->value)) && $r->moveToAttribute('from') && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:TazeTSchnitzel,项目名称:phd,代码行数:21,代码来源:Base.php

示例9: addslashes

     $affectedProducts .= mysql_prep($reader->value);
     $affectedProducts .= mysql_prep("<br>");
 }
 if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == "affectedProducts" && $isAdvisory == "true") {
     $isAffectedProducts = "false";
     $affectedProducts = addslashes($affectedProducts);
 }
 /*REFERENCES - LINKS*/
 if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "references" && $isAdvisory == "true") {
     $isReferences = "true";
 }
 if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "link" && $isReferences == "true") {
     $reader->moveToAttribute('target');
     $linkTarget .= mysql_prep($reader->value);
     $linkTarget .= ",";
     $reader->moveToElement();
     $reader->read();
     $linkName .= mysql_prep($reader->value);
     $linkName .= ",";
 }
 if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == "references" && $isReferences == "true") {
     $isReferences = "false";
     $linkName = mysql_prep($linkName);
     $linkTarget = mysql_prep($linkTarget);
 }
 /*FIX RECOMMENDATION*/
 if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "fixRecommendation" && $isAdvisory == "true") {
     $isFixRecommendation = "true";
     $reader->moveToAttribute('type');
     $fixRecommendation_type = mysql_prep($reader->value);
     $fixRecommendation = mysql_prep("<p>");
开发者ID:mageni,项目名称:projectrf,代码行数:31,代码来源:parse.php

示例10: parse

 /**
  * Parses the input code and returns the OPT XML tree.
  *
  * @param String $filename The file name (for debug purposes)
  * @param String &$code The code to parse
  * @return Opt_Xml_Root
  */
 public function parse($filename, &$code)
 {
     $debug = array(XMLReader::NONE => 'NONE', XMLReader::ELEMENT => 'ELEMENT', XMLReader::ATTRIBUTE => 'ATTRIBUTE', XMLReader::TEXT => 'TEXT', XMLReader::CDATA => 'CDATA', XMLReader::ENTITY_REF => 'ENTITY_REF', XMLReader::ENTITY => 'ENTITY', XMLReader::PI => 'PI', XMLReader::COMMENT => 'COMMENT', XMLReader::DOC => 'DOC', XMLReader::DOC_TYPE => 'DOC_TYPE', XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT', XMLReader::NOTATION => 'NOTATION', XMLReader::WHITESPACE => 'WHITESPACE', XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE', XMLReader::END_ELEMENT => 'END_ELEMENT', XMLReader::END_ENTITY => 'END_ENTITY', XMLReader::XML_DECLARATION => 'XML_DECLARATION');
     libxml_use_internal_errors(true);
     $reader = new XMLReader();
     $reader->xml($code);
     //	$reader->setParserProperty(XMLReader::LOADDTD, true);
     //	$reader->setParserProperty(XMLReader::VALIDATE, true);
     $reader->setParserProperty(XMLReader::SUBST_ENTITIES, true);
     $root = $current = new Opt_Xml_Root();
     $firstElementMatched = false;
     $depth = 0;
     // Thanks, Oh Great PHP for your excellent WARNINGS!!! >:(
     while (@$reader->read()) {
         if ($reader->depth < $depth) {
             $current = $current->getParent();
         } elseif ($reader->depth > $depth) {
             $current = $optNode;
         }
         //	Opl_Debug::write($debug[$reader->nodeType].': '.$reader->name.', '.$reader->value);
         switch ($reader->nodeType) {
             // XML elements
             case XMLReader::ELEMENT:
                 $optNode = new Opt_Xml_Element($reader->name);
                 // Parse element attributes, if you manage to get there
                 if ($reader->moveToFirstAttribute()) {
                     do {
                         // "xmlns" special namespace must be handler somehow differently.
                         if ($reader->prefix == 'xmlns') {
                             $ns = str_replace('xmlns:', '', $reader->name);
                             $root->addNamespace($ns, $reader->value);
                             // Let this attribute to appear, if it does not represent an OPT special
                             // namespace
                             if (!$this->_compiler->isNamespace($ns)) {
                                 $optAttribute = new Opt_Xml_Attribute($reader->name, $reader->value);
                                 $optNode->addAttribute($optAttribute);
                             }
                         } else {
                             $optAttribute = new Opt_Xml_Attribute($reader->name, $reader->value);
                             $optNode->addAttribute($optAttribute);
                         }
                     } while ($reader->moveToNextAttribute());
                     $reader->moveToElement();
                 }
                 // Set "rootNode" flag
                 if (!$firstElementMatched) {
                     $optNode->set('rootNode', true);
                     $firstElementMatched = true;
                 }
                 // Set "single" flag
                 if ($reader->isEmptyElement) {
                     $optNode->set('single', true);
                 }
                 $current->appendChild($optNode);
                 break;
             case XMLReader::TEXT:
                 $this->_treeTextCompile($current, $reader->value);
                 break;
             case XMLReader::COMMENT:
                 $optNode = new Opt_Xml_Comment($reader->value);
                 $current->appendChild($optNode);
                 break;
             case XMLReader::CDATA:
                 $cdata = new Opt_Xml_Cdata($reader->value);
                 $cdata->set('cdata', true);
                 if ($current instanceof Opt_Xml_Text) {
                     $current->appendChild($cdata);
                 } else {
                     $text = new Opt_Xml_Text();
                     $text->appendChild($cdata);
                     $current->appendChild($text);
                     $current = $text;
                 }
                 break;
                 /*		case XMLReader::SIGNIFICANT_WHITESPACE:
                 					$cdata = new Opt_Xml_Cdata($reader->value);
                 					$cdata->set('cdata', true);
                 
                 					if($current instanceof Opt_Xml_Text)
                 					{
                 						$current->appendChild($cdata);
                 					}
                 					else
                 					{
                 						$text = new Opt_Xml_Text();
                 						$text->appendChild($cdata);
                 						$current->appendChild($text);
                 						$current = $text;
                 					}
                 					break;
                 		 */
         }
         $depth = $reader->depth;
//.........这里部分代码省略.........
开发者ID:OPL,项目名称:Open-Power-Template,代码行数:101,代码来源:Xml.php

示例11: generateDeprecatedInfo

 protected static function generateDeprecatedInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     if (!is_file($filename)) {
         v("Can't find Version information file (%s), skipping!", $filename, E_USER_WARNING);
         return array();
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         v("Can't open the version info file (%s)", $filename, E_USER_ERROR);
     }
     $deprecated = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("_", "_", "_", "_", ""), $r->value)) && $r->moveToAttribute("deprecated") && ($value = $r->value)) {
             $deprecated[strtolower($funcname)] = $value;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $deprecated;
     return $deprecated;
 }
开发者ID:TazeTSchnitzel,项目名称:phd,代码行数:25,代码来源:XHTML.php

示例12: XMLReader

<?php

/* $Id$ */
$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
<books><book num="1"></book><test /></books>';
$reader = new XMLReader();
$reader->XML($xmlstring);
// 2 read to get on the 2nd node
$reader->read();
$reader->read();
if ($reader->nodeType != XMLREADER::END_ELEMENT) {
    if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
        $attr = $reader->moveToFirstAttribute();
        if ($reader->moveToElement()) {
            if ($reader->name == 'book') {
                echo "ok\n";
            }
        }
    }
}
$reader->close();
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:006.php

示例13: moveToElement

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


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