本文整理汇总了PHP中XMLParser::ReturnArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::ReturnArray方法的具体用法?PHP XMLParser::ReturnArray怎么用?PHP XMLParser::ReturnArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::ReturnArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function _ResponseResultToResponseArray($SomeResult)
{
$this->responsearray = array();
if (empty($SomeResult)) {
// $SomeArray
// we have an error
$this->responsearray['status'] = 'Error';
$this->responsearray['statusCode'] = '500';
$this->responsearray['errorDescription'] = 'No Response';
return;
}
//echo '<br>$this->ContentType='.$this->ContentType.'<br>';
if ($this->ContentType != 'JSON' && $this->ContentType != 'PHPSERIAL' && $this->ContentType != 'XML') {
$this->ContentType = 'JSON';
}
//echo '<br>$this->ContentType='.$this->ContentType.'<br>';
if ($this->ContentType == 'JSON') {
if (class_exists('Services_JSON')) {
//$JSONObj = new Services_JSON();
//return $JSONObj->encode($SomeArray);
$JSONObj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$this->responsearray = $JSONObj->decode($SomeResult);
} else {
// throw error
trigger_error("ERROR: Services_JSON class not available", E_USER_ERROR);
}
} else {
if ($this->ContentType == 'XML') {
if (class_exists('XMLParser')) {
$parser = new XMLParser($SomeResult, false, false);
$parser->Parse();
$this->responsearray = $parser->ReturnArray();
$this->responsearray = $this->responsearray['root'];
// this forces the 'results' response to always have a child 0, xml can omit this
if (isset($this->responsearray['results']) && is_array($this->responsearray['results']) && !isset($this->responsearray['results']['0']) && count($this->responsearray['results'] > 0)) {
$temparray = $this->responsearray['results'];
unset($this->responsearray['results']);
$this->responsearray['results']['0'] = $temparray;
unset($temparray);
}
//$XMLObj = new ArrayXML( $SomeArray );
//return '<'.'?'.'xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<root>'."\n".$XMLObj->ReturnXML().'</root>';
} else {
// throw error
trigger_error("ERROR: XMLParser class not available", E_USER_ERROR);
}
} else {
if ($this->ContentType == 'PHPSERIAL') {
//return serialize($SomeArray);
$this->responsearray = unserialize($SomeResult);
//if ( is_array( $this->xmlarray ) )
//{
// $this->xmlarray['root'] = array_changekeycase_r( $this->xmlarray['root'], CASE_LOWER );
//}
}
}
}
if (!empty($this->responsearray['status'])) {
$this->Status = $this->responsearray['status'];
}
if (!empty($this->responsearray['statusCode'])) {
$this->StatusCode = $this->responsearray['statusCode'];
}
if (!empty($this->responsearray['errorDescription'])) {
$this->ErrorDescription = $this->responsearray['errorDescription'];
}
// $this->responsearray['status'] = 'Success'
// $this->responsearray['statusCode'] = '200'
//}
// default
//$JSONObj = new Services_JSON();
//return $JSONObj->encode($SomeArray);
}