本文整理汇总了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'));
}
示例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'));
}
示例3: retrieveXml
public function retrieveXml($url)
{
$content = $this->downloadHttp($url);
$result = @opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
return $result;
}
示例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');