You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

4 years ago
<?php
namespace AliyunMNS\Common;
class XMLParser
{
/**
* Most of the error responses are in same format.
*/
static function parseNormalError(\XMLReader $xmlReader) {
$result = array('Code' => NULL, 'Message' => NULL, 'RequestId' => NULL, 'HostId' => NULL);
while ($xmlReader->Read())
{
if ($xmlReader->nodeType == \XMLReader::ELEMENT)
{
switch ($xmlReader->name) {
case 'Code':
$xmlReader->read();
if ($xmlReader->nodeType == \XMLReader::TEXT)
{
$result['Code'] = $xmlReader->value;
}
break;
case 'Message':
$xmlReader->read();
if ($xmlReader->nodeType == \XMLReader::TEXT)
{
$result['Message'] = $xmlReader->value;
}
break;
case 'RequestId':
$xmlReader->read();
if ($xmlReader->nodeType == \XMLReader::TEXT)
{
$result['RequestId'] = $xmlReader->value;
}
break;
case 'HostId':
$xmlReader->read();
if ($xmlReader->nodeType == \XMLReader::TEXT)
{
$result['HostId'] = $xmlReader->value;
}
break;
}
}
}
return $result;
}
}
?>