避免由于缺少结束标记而导致responseXML错误

时间:2019-01-04 16:26:26

标签: ajax xml response mime-types wms

我正在尝试将AJAX请求的响应解析为XML。

由于它可能具有不同的Mime类型,因此我首先通过overrideMimeType()将其作为XML。

在大多数情况下都可以使用,但是当我尝试覆盖this URL(使用 <?php namespace ControlPanelTest\Controller; use ControlPanel\Controller\ControlPanelController; use Zend\Stdlib\ArrayUtils; use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; use ZfcRbac\Identity\IdentityInterface; use ZfcRbac\Identity\IdentityProviderInterface; use ZfcRbac\Service\RoleService; class AgentControllerTest extends AbstractHttpControllerTestCase { protected $traceError = true; protected $guard; public function setUp() { $configOverrides = []; $this->setApplicationConfig(ArrayUtils::merge( // Grabbing the full application configuration: include __DIR__ . '/../../../../config/application.config.php', $configOverrides )); parent::setUp(); } public function rbacGuards($roles) { /** * Deal with Rbac Guards */ $roleService = $this->getApplicationServiceLocator()->get(RoleService::class); $identityProvider = $this->prophesize(IdentityProviderInterface::class); $identity = $this->prophesize(IdentityInterface::class); // Here you use the setter to inject your mocked identity provider $roleService->setIdentityProvider($identityProvider->reveal()); $identityProvider->getIdentity()->shouldBeCalled()->willReturn($identity->reveal()); $identity->getRoles()->shouldBeCalled()->willReturn($roles); } public function testModuleActionsCanBeAccessed() { $this->rbacGuards(['admin']); $this->dispatch('/cp/overview'); $this->assertResponseStatusCode(200); $this->assertModuleName('ControlPanel'); $this->assertControllerName(ControlPanelController::class); $this->assertControllerClass('ControlPanelController'); $this->assertMatchedRouteName('cp/overview'); } } 查看其来源)时,responseXML()显然会失败,因为缺少CTRL+U标签。

</meta>

我无法控制所请求的数据,因此无法自己添加标签。

我执行此转换的原因是在发生异常的情况下解析响应并捕获其消息(资源实际上表示Web Map Service或WMS)。

thera是否可以解决此问题?

这是我正在使用的代码的一部分:

TypeError: xhr is null
Errore interpretazione XML: tag corrispettivo mancante. Previsto: </meta>.

0 个答案:

没有答案