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


PHP Zend_Dom_Query::queryXPath方法代码示例

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


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

示例1: parse

 protected function parse($manifestFile)
 {
     $this->manifestFile = $manifestFile;
     if (!file_exists($manifestFile)) {
         throw new Exception('Manifest file not found');
     }
     /* @var $dom Zend_Dom_Query */
     $dom = new Zend_Dom_Query(@file_get_contents($manifestFile));
     $this->m_label = $dom->queryXPath('/vs-manifest/metadata/label')->current()->nodeValue;
     $this->m_description = $dom->queryXPath('/vs-manifest/metadata/description')->current()->nodeValue;
     $this->m_file = $dom->queryXPath('/vs-manifest/metadata/file')->current()->nodeValue;
     $this->m_class = $dom->queryXPath('/vs-manifest/metadata/class')->current()->nodeValue;
     $this->m_version = $dom->queryXPath('/vs-manifest/metadata/version')->current()->nodeValue;
     $this->m_key = $dom->queryXPath('/vs-manifest/metadata/key')->current()->nodeValue;
     $this->m_c_from = $dom->queryXPath('/vs-manifest/metadata/compatibility/from')->current()->nodeValue;
     try {
         $this->m_c_to = $dom->queryXPath('/vs-manifest/metadata/compatibility/to')->current()->nodeValue;
     } catch (Exception $e) {
         $this->m_c_to = null;
     }
     // if there is no TO, it isn't a problem
     $filesXPath = $dom->queryXPath('/vs-manifest/files//file');
     while ($filesXPath->valid()) {
         $node = $filesXPath->current();
         $properties = array();
         for ($i = 0; $i < $node->attributes->length; $i++) {
             $properties[$node->attributes->item($i)->nodeName] = $node->attributes->item($i)->nodeValue;
         }
         $filename = $node->nodeValue;
         $parentStack = array();
         $parent = $node->parentNode;
         while ($parent != null && !($parent->nodeName == 'files' && $parent->parentNode->nodeName == 'vs-manifest')) {
             // we are at top
             $parentStack[] = $parent->nodeName;
             $parent = $parent->parentNode;
         }
         $path = implode('/', array_reverse($parentStack, false));
         if ($properties) {
             X_Debug::i("Properties for {{$path}/{$filename}}: " . print_r($properties, true));
         }
         $this->files[] = new X_Egg_File("{$path}/{$filename}", $this->basePath, $this->destinationPath, $properties);
         $filesXPath->next();
     }
     try {
         $this->installSql = @$dom->queryXPath('/vs-manifest/database/install')->current()->nodeValue;
     } catch (Exception $e) {
         $this->installSql = null;
     }
     // if there is no TO, it isn't a problem
     try {
         $this->uninstallSql = @$dom->queryXPath('/vs-manifest/database/uninstall')->current()->nodeValue;
     } catch (Exception $e) {
         $this->uninstallSql = null;
     }
     // if there is no TO, it isn't a problem
     // new fragment of manifest about acl
     $aclClassesXPath = $dom->queryXPath('/vs-manifest/acl/classes/class');
     while ($aclClassesXPath->valid()) {
         $node = $aclClassesXPath->current();
         $properties = array();
         for ($i = 0; $i < $node->attributes->length; $i++) {
             $properties[$node->attributes->item($i)->nodeName] = $node->attributes->item($i)->nodeValue;
         }
         $classname = $node->nodeValue;
         $this->acl_classes[] = new X_Egg_AclClass($classname, $properties);
         $aclClassesXPath->next();
     }
     // new fragment of manifest about acl
     $aclResourcesXPath = $dom->queryXPath('/vs-manifest/acl/resources/resource');
     while ($aclResourcesXPath->valid()) {
         $node = $aclResourcesXPath->current();
         $properties = array();
         for ($i = 0; $i < $node->attributes->length; $i++) {
             $properties[$node->attributes->item($i)->nodeName] = $node->attributes->item($i)->nodeValue;
         }
         $key = $node->nodeValue;
         $this->acl_resources[] = new X_Egg_AclResource($key, $properties);
         $aclResourcesXPath->next();
     }
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:80,代码来源:Egg.php


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