本文整理汇总了PHP中Converter::xml2array方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::xml2array方法的具体用法?PHP Converter::xml2array怎么用?PHP Converter::xml2array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::xml2array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testArray2xml
/**
* @dataProvider providerTestArray2xml
*/
public function testArray2xml($data, $actual, $exceptionName = '')
{
if ($exceptionName) {
$this->setExpectedException($exceptionName);
}
$expected = Converter::array2xml($data);
$this->assertEquals($expected, $actual);
//reverse test
$tmp = Converter::xml2array($expected);
$expected = Converter::array2xml($tmp);
$this->assertEquals($expected, $actual);
}
示例2: loadConfig
public static function loadConfig($configFilename, $type = 'xml')
{
switch ($type) {
case 'php':
$data = (include $configFilename);
break;
case 'xml':
$contents = file_get_contents($configFilename);
$data = Converter::xml2array($contents);
break;
default:
$message = 'Ivalid type';
throw new BuildException($message);
}
return $data;
}
示例3: _saveToPhp
protected function _saveToPhp($filename, $xmlString)
{
$data = Converter::xml2array($xmlString);
$content = sprintf('<?php return %s;', var_export($data, true));
$result = file_put_contents($filename, $content);
return $result;
}
示例4: _doWork
private function _doWork()
{
$srcFileList = $this->_srcFileListArr;
$cnt = count($srcFileList);
$msg = sprintf("Start xmlmerge files: \n\t - %s", implode("\n\t - ", $srcFileList));
$this->log($msg);
$result = '';
$mergeData = array();
for ($i = 0; $i < $cnt; $i++) {
if (empty($srcFileList[$i])) {
continue;
}
$srcFile = $this->_geFullPath($srcFileList[$i]);
$contents = file_get_contents($srcFile);
try {
$data = Converter::xml2array($contents);
$mergeData = Tools::arrayMergeRecursive($mergeData, $data);
} catch (BuildException $e) {
$message = $e->getMessage() . ' File: ' . $srcFile;
throw new BuildException($message);
}
}
$dstFile = $this->_geFullPath($this->_dstFile);
$this->_save($mergeData, $dstFile);
$msg = sprintf("Complete xmlmerge\nSaved (%s) into file: (%s)", count($result), $dstFile);
$this->log($msg);
}