本文整理汇总了PHP中XString::xmlToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XString::xmlToArray方法的具体用法?PHP XString::xmlToArray怎么用?PHP XString::xmlToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XString
的用法示例。
在下文中一共展示了XString::xmlToArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWrap
public function testWrap()
{/*{{{*/
$dir = dirname(__FILE__);
$wrapper = new Wrapper;
$xsltFile = $dir.'/demo.xslt';
$xmlFile = $dir.'/demo.xml';
$result = $wrapper->wrap($xsltFile, $xmlFile);
$expectedRes = '<?xml version="1.0" encoding="gbk"?>
<document>
<item>
<hospitalfacultyname>testÒ½Ôºtest¿Æ</hospitalfacultyname>
<url>www.haodf.com</url>
</item>
</document>';
$resArray = XString::xmlToArray($result);
$expectedResArray = XString::xmlToArray($expectedRes);
$this->assertEquals($expectedResArray, $resArray);
}/*}}}*/
示例2: testFile
public function testFile()
{/*{{{*/
$maxFileSize = 10*1024*1024;
$maxItemCount = 10000;
$configs = BeanFinder::get('configs');
$dataPath = $configs->dataPath."complete/";
//文件夹存在
$this->assertTrue(is_dir($dataPath));
//取所有文件夹下的文件
$dirList = XString::listDir($dataPath);
if ($dirList)
{
foreach ($dirList as $dir)
{
$fileList = XString::listFile($dataPath.$dir);
foreach ($fileList as $file)
{
//单个文件不超过10M
$this->assertFalse((filesize($file) > $maxFileSize), $file."过大\n");
}
}
foreach ($dirList as $dir)
{
$fileList = XString::listFile($dataPath.$dir);
foreach ($fileList as $file)
{
$xmlData = $xmlHospitalList = $xmlHospital = array();
$xmlData = file_get_contents($file);
$xmlHospitalList = XString::xmlToArray($xmlData);
if (isset($xmlHospitalList['item']) && $xmlHospitalList['item'])
{
//每个文件数量不超过10000
$xmlHospital = array_pop($xmlHospitalList['item']);
$this->assertFalse(count($xmlHospital) > $maxItemCount);
}
}
}
}
}/*}}}*/
示例3: __construct
public function __construct($request, $response)
{/*{{{*/
$ioFaculty = new IOFaculty();
$this->IOConverter = $ioFaculty->run(IOFaculty::TYPE_XML);
$response->confLogPath = PhoneConferenceClient::getInstance()->getConfLogPath();
$items = '';
if ($request instanceof Request && CallCenterApiFaculty::SPTYPE_CLOUD != $request->callbacktype)
{
$arr = $request->getAllRequest();
$items = $this->getLogStr($arr);
}
else
{
$items = file_get_contents("php://input");
$items = preg_replace("/<S.* \/>/","",$items);
$items = $this->getLogStr(XString::xmlToArray($items));
}
$this->logTxt .= XDateTime::now()->toString().$items."\n";
$this->setCallBack($request->callbacktype, $response);
}/*}}}*/
示例4: xmlData
private function xmlData($filePath="", $type = 'baidu')
{/*{{{*/
$xml = array();
if ($filePath)
{
$xmlData = file_get_contents($filePath);
$xmlDataList = XString::xmlToArray($xmlData);
if ($xmlDataList)
{
if ($type == 'baidu')
{
$xml = array_pop($xmlDataList['item']);
}
elseif ($type == 'soso')
{
$xml = array_pop($xmlDataList['datalist']['item']);
}
}
}
$this->assertFalse(empty($xml), "没有内容\n");
return XString::convertEncoding($xml, 'GBK', 'auto');
}/*}}}*/
示例5: initCallBackData
public function initCallBackData(array $data, $name)
{
/*{{{*/
$sign = $data["sign"];
$content = "notify_data=" . $data["notify_data"];
$res = $this->verify($content, $sign);
if (false == $res) {
return $res;
} else {
$out_trade_no = $this->getDataForXML($data["notify_data"], '/notify/out_trade_no');
list($sn, $type) = Pay::explodeSN($out_trade_no);
Pay::checkNameInValidNames($name);
$this->sn = $sn;
$this->name = $name;
$this->type = Pay::$typeDescs[$type];
$arrcontent = XString::xmlToArray($data["notify_data"]);
$arrcontent['name'] = $name;
$arrcontent = XString::convertEncoding($arrcontent, 'gbk', 'utf8');
$this->content = $arrcontent;
$this->total_fee = $this->getDataForXML($data["notify_data"], '/notify/total_fee');
$this->total_fee = (array) $this->total_fee;
$this->total_fee = $this->total_fee[0];
$this->trade_status = $this->getDataForXML($data["notify_data"], '/notify/trade_status');
$this->trade_status = (array) $this->trade_status;
$this->trade_status = $this->trade_status[0];
$this->data = $arrcontent;
return $this;
}
}
示例6: initCallBackData
public function initCallBackData(array $data, $name)
{
/*{{{*/
$waperAlipayFunction = wap_alipay_function::getInstance();
$out_trade_no = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/out_trade_no');
list($sn, $type) = Pay::explodeSN($out_trade_no);
Pay::checkNameInValidNames($name);
$this->sn = $sn;
$this->name = $name;
$this->type = Pay::$typeDescs[$type];
$arrcontent = XString::xmlToArray($data["notify_data"]);
$arrcontent['name'] = $name;
$arrcontent = XString::convertEncoding($arrcontent, 'gbk', 'utf8');
$this->content = $arrcontent;
$this->total_fee = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/total_fee');
$this->total_fee = (array) $this->total_fee;
$this->total_fee = $this->total_fee[0];
$this->trade_status = $waperAlipayFunction->getDataForXML($data["notify_data"], '/notify/trade_status');
$this->trade_status = (array) $this->trade_status;
$this->trade_status = $this->trade_status[0];
$this->data = $arrcontent;
return $this;
}