本文整理汇总了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();
}
}