當前位置: 首頁>>代碼示例>>PHP>>正文


PHP opToolkit::loadXmlString方法代碼示例

本文整理匯總了PHP中opToolkit::loadXmlString方法的典型用法代碼示例。如果您正苦於以下問題:PHP opToolkit::loadXmlString方法的具體用法?PHP opToolkit::loadXmlString怎麽用?PHP opToolkit::loadXmlString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在opToolkit的用法示例。


在下文中一共展示了opToolkit::loadXmlString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPackageInfo

 protected function getPackageInfo()
 {
     $xmlPath = sfConfig::get('sf_plugins_dir') . '/' . $this->getName() . '/package.xml';
     if (!is_readable($xmlPath)) {
         return false;
     }
     $content = file_get_contents($xmlPath);
     return opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:9,代碼來源:opPlugin.class.php

示例2: execute

 protected function execute($arguments = array(), $options = array())
 {
     // Remove E_STRICT and E_DEPRECATED from error_reporting
     error_reporting(error_reporting() & ~(E_STRICT | E_DEPRECATED));
     require_once 'Archive/Tar.php';
     $pluginName = $arguments['name'];
     $packagePath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName;
     if (!is_readable($packagePath . '/package.xml')) {
         throw new sfException(sprintf('Plugin "%s" dosen\'t have a definition file.', $pluginName));
     }
     $content = file_get_contents($packagePath . '/package.xml');
     $infoXml = opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
     $filename = sprintf('%s-%s.tgz', (string) $infoXml->name, (string) $infoXml->version->release);
     $dirPath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName;
     $tar = new Archive_Tar($arguments['dir'] . '/' . $filename, true);
     foreach ($infoXml->contents->dir->file as $file) {
         $attributes = $file->attributes();
         $name = (string) $attributes['name'];
         $tar->addString($pluginName . '-' . (string) $infoXml->version->release . '/' . $name, file_get_contents($dirPath . '/' . $name));
     }
     $tar->addString('package.xml', file_get_contents($dirPath . '/package.xml'));
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:22,代碼來源:opPluginArchiveTask.class.php

示例3: retrieveXml

 public function retrieveXml($url)
 {
     $content = $this->downloadHttp($url);
     $result = @opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
     return $result;
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:6,代碼來源:opPearRest.class.php

示例4: dirname

<?php

include_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(null, new lime_output_color());
$t->diag('opToolkit::loadXmlString()');
$path_to_feed = realpath(dirname(__FILE__) . '/../../fixtures/feeds/www.xss.feed.rss');
$xml = '<a id="root">ok</a>';
$xml_with_xxe = '<!DOCTYPE a [<!ENTITY xxe SYSTEM "file://' . $path_to_feed . '">]><a id="root">ok&xxe;</a>';
$t->comment('with no external entities');
$t->isa_ok(opToolkit::loadXmlString($xml), 'DOMDocument', 'returns an instance of "DOMDocument"');
$t->isa_ok(opToolkit::loadXmlString($xml, array('return' => 'SimpleXMLElement')), 'SimpleXMLElement', 'returns an instanceof "SimpleXMLElement"');
$t->comment('with external entities');
$t->isa_ok(opToolkit::loadXmlString($xml_with_xxe), 'DOMDocument', 'returns an instance of "DOMDocument"');
$t->isa_ok(opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement')), 'SimpleXMLElement', 'returns an instanceof "SimpleXMLElement"');
$t->is(opToolkit::loadXmlString($xml_with_xxe)->textContent, 'ok', 'generated XML string by "DOMDocument" does not have entitied value');
$t->is((string) opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement')), 'ok', 'generated XML string by "SimpleXMLElement" does not have entitied value');
$t->isnt(opToolkit::loadXmlString($xml_with_xxe, array('loadEntities' => true))->textContent, 'ok', 'generated XML string by "DOMDocument" has entitied value if "loadEntities" option is specified');
$t->isnt((string) opToolkit::loadXmlString($xml_with_xxe, array('return' => 'SimpleXMLElement', 'loadEntities' => true)), 'ok', 'generated XML string by "SimpleXMLElement" has entitied value if "loadEntities" option is specified');
開發者ID:te-koyama,項目名稱:openpne,代碼行數:18,代碼來源:opToolkitLoadXmlStringTest.php


注:本文中的opToolkit::loadXmlString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。