From last couple of days, I was struggling with an Authorized.net Transaction Details API.
The code I am working with is written in namespaces/blocks, so the problem I was facing is just like below.
SimpleXMLElement::__construct(): Entity: line 1: parser warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute in /classes/anet_php_sdk/lib/AuthorizeNetTD.php on line 188
To get rid of these warning you have to follow some simple steps as below. I am assuming you are working with Authorized.net SDK Package, have downloaded by below URL. http://developer.authorize.net/downloads/
You have to update some small changes in 2 files.
1. anet_php_sdk\lib\AuthorizeNetTD.php
2. anet_php_sdk\lib\shared\AuthorizeNetXMLResponse.php
In first step open file “AuthorizeNetTD.php”. Find method “_constructXml”, in this method replace first 2 lines
<?php $string = '<'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'; $this->_xml = @new SimpleXMLElement($string); ?>
By below 3 lines of code
<?php $string = '<'.$request_type.'>'; $this->_xml = @new SimpleXMLElement($string); $this->_xml->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'); ?>
Now open “AuthorizeNetXMLResponse.php”. Copy/Paste the below method in the class.
<?php /* @refer http://community.developer.authorize.net/t5/Integration-and-Testing/ARB-with-SimpleXML-PHP-Issue/m-p/7128#M5139*/ private function removeResponseXMLNS($input) { // Remove XML response namespaces one by one $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"','',$input); $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','',$input); return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input); } ?>
Use this method in the constructor “__construct” of the class or replace this
$this->xml = @simplexml_load_string($response);
By this
$this->xml = @simplexml_load_string($this->removeResponseXMLNS($response));
Thanks for telling me about transaction detail, I am from last two days continue facing the problem, Your article is very helpful for me to reduce my headach of warning messages
Thanks again